Phone Controller
ConnectivityPhoneController is a source block that turns any smartphone into a wireless joystick plus an independent yaw dial. When the block is placed on the canvas it shows a pairing QR code; scanning it opens a controller page on the phone with a large on-screen touch joystick and a horizontal yaw strip below it. The phone streams normalized X/Y/Yaw control values (â1âĻ+1) into the simulation at ~30 Hz over the same WebRTC peer-to-peer channel used by the RemoteSensor block â no cables, no app install.
Two control modes are available for the joystick pad on the phone (the yaw strip works the same in both):
- Touch (default): thumb on the on-screen joystick pad. Release springs back to center.
- Tilt: uses the phone's orientation sensors (DeviceOrientation). Tilt left/right maps to X, tilt forward/back maps to Y. The neutral pose is calibrated when the mode is enabled; tap the pad to re-center at any time.
The yaw strip is a separate horizontal drag control below the pad â drag left/right, release to spring back to 0. It's always active regardless of touch/tilt mode.
Use this block for interactive demos where a mouse feels clumsy: flying a simulated drone, steering a vehicle model, or driving a setpoint through a control loop by hand. Its X/Y output ports are named identically to Joystick2D's, so it's a drop-in wireless replacement anywhere an on-canvas joystick is wired up â including the Fly the Quadcopter (Phone) template, which also wires the Yaw port to the drone's yaw axis.
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| ← Out | x |
X | number | Output |
| ← Out | y |
Y | number | Output |
| ← Out | yaw |
Yaw | number | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
playoutDelay |
Playout Delay (ms) | number | 80 |
Network jitter buffer. Lower = more responsive control, higher = smoother signal on flaky connections. |
interpolation |
Interpolation | select | linear |
How to reconstruct the control signal between received joystick packets. |
outputLabels |
Output Labels | vector | x,y,yaw |
Usage Examples
Phone Joystick â Attitude Demo
Load the bundled Phone Joystick â Attitude Demo (block examples menu). Your thumb commands the attitude of a simulated quadcopter: X becomes a roll setpoint, Y a pitch setpoint, each shaped by second-order attitude dynamics and rendered on a 3D gimbal:
PhoneController âââē [X] âââē Gain(30) âââē 2nd Order System âââē Gimbal3D [roll]
âââē [Y] âââē Gain(30) âââē 2nd Order System âââē Gimbal3D [pitch]
Scan the QR code, press Grab Control, start the simulation â the drone follows your thumb.
Fly the full quadcopter template wirelessly
The Fly the Quadcopter (Phone) template (Examples menu â Control Systems) wires all three ports â x/y to the roll/pitch PID loops (through a Gain, same as Joystick2D's built-in gain) and yaw straight to the yaw PID loop â driving the full three-axis PID + motor mixer + 3D gimbal. No on-canvas slider needed: the phone's yaw strip covers it.
Manual setpoint for a PID loop
PhoneController âââē [Y] âââē Gain âââē (setpoint) Subtraction âââē PIDController â plantRemarks & Best Practices
- Source block: All three channels are output ports (right side). X is positive to the right, Y is positive forward/up (pushing the joystick up gives +1), Yaw is positive to the right of the strip.
- Fixed 30 Hz stream: The phone transmits continuously â also when centered â to keep the playout buffer warm and the latency estimate stable.
- Dead zone: A small dead zone (Âą0.02) is applied on the phone so a resting thumb/handle yields exactly 0.
- Simulation waits for pairing: Like all live-hardware blocks, the simulation start is gated until the phone is connected and the first packets have arrived.
- WebRTC required: Phone and desktop both need internet access for the PeerJS signalling handshake. Self-hosted PeerJS servers are supported via the same
localStoragekeys as RemoteSensor (blockwerk_peer_host/blockwerk_peer_port/blockwerk_peer_path/blockwerk_peer_secure). - One controller per diagram: The X/Y/Yaw channels are global (
remote:joy.x/remote:joy.y/remote:joy.z); two PhoneController blocks would receive the same data. - Output values when disconnected: All three ports hold
0until the phone connects and begins transmitting.
Related Components
- RemoteSensor: Stream the phone's accelerometer, gyroscope, magnetometer, barometer, and GPS instead of a joystick.
- ExternalInput: Lightweight source for manually injected or scripted numeric values.
- Gimbal3D: 3D attitude visualization â the natural sink for this block's demo.