Docs

Joystick

The Joystick sends two numbers at once: X and Y.

Use it for: a robot on wheels, a pan and tilt camera head, an RC boat, anything you steer.

SettingWhat it does
Pinone pin carrying both axes
Split modetwo separate pins, one per axis
X range, Y rangethe values sent at the edges
Auto returnsnap back to centre when you let go
Rotate on tiltturn the control with the phone

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

The two settings that matter

Auto return decides what happens when you lift your thumb. With it on, the stick snaps to the centre and sends that value, which stops a motor. With it off, the last value stays and the robot keeps going. Turn it on for anything that moves.

Split mode swaps one pin for two, one per axis. Your sketch then reads a plain param.asInt() in two separate handlers instead of param[0] and param[1]. Use merged unless the axes already live on separate pins in your code.

Example

Two axes on V14 driving a pan and tilt head.

joystick.ino
#include <PlynxSimpleEsp32.h>

#include <ESP32Servo.h>

Servo pan;
Servo tilt;

// Merged mode sends both axes in one message.
PLYNX_WRITE(V14)
{
  int x = param[0].asInt();           // 0 to 180 with that widget range
  int y = param[1].asInt();

  pan.write(x);
  tilt.write(y);
}

void setup()
{
  Serial.begin(115200);

  pan.attach(18);
  tilt.attach(19);

  // Auto setup: WiFi and the Plynx token are configured from the app.
  //
  // To provide them directly in the sketch instead, use:
  //   Plynx.begin(auth, ssid, pass);
  Plynx.begin();
}

void loop()
{
  Plynx.run();
}

param[0] is X and param[1] is Y. Split mode replaces them with two separate PLYNX_WRITE() handlers, each reading a plain param.asInt().

Set the widget range to match what you drive. 0 to 180 suits a servo, -255 to 255 suits a motor driver that takes direction from the sign.

Values arrive while you move

The stick sends continuously while your thumb moves. Keep the handler to the two writes it needs.

For a robot, add a safety timeout: if nothing arrives for a second, stop the motors. A dropped connection leaves the last value in place otherwise, and the robot drives into a wall.

Troubleshooting

ProblemCheck
Only one axis respondssplit mode is on but the sketch reads param[0..1]
Motors run after you let goAuto return is off, or your code has no timeout
Movement is coarsethe widget range is smaller than the range you drive
Board drops out while steeringthe handler is doing too much work

Next