A beginner-friendly wireless robot controller library for the Arduino Uno R4 WiFi.
This library allows you to control a robot from a phone or computer using a built-in web interface with:
- 🕹️ Joystick control
- 🎚️ Throttle slider
- 🔘 Custom buttons
- 🛑 Built-in failsafe safety
- 💡 Status LED indicators
- 🔧 Optional L298N motor driver support
The goal is to replace fragile hardware joystick controllers with a reliable wireless interface.
- Arduino Uno R4 WiFi
- L298N motor driver (if using motors)
- DC motors
- Robot battery
- Phone or computer with WiFi
- Download the
Controllerzipped-library from thereleasessection. - Save the zip file to your computer.
- Open Arduino IDE.
- Go to:
Sketch > Include Library > Add .ZIP Library
- Select the zip file.
Add this at the top of your sketch:
#include <Controller.h>The constructor requires:
Controller controller("SSID", "password");Example:
Controller controller("RobotAP", "12345678");This creates a WiFi network named RobotAP.
In setup():
void setup() {
Serial.begin(115200);
controller.beginAP(true); // true = enable debug
}true→ enables debug printingfalse→ disables debug mode
In loop():
void loop() {
controller.update();
}This is mandatory.
It handles:
- Web requests
- Joystick input
- Motor smoothing
- Failsafe safety
- Power the robot.
- Connect your phone/laptop to the WiFi network you defined.
- Open a browser.
- Go to:
http://10.0.0.2
controller.configureL298N(
9, 7, 6, // ENA, IN1, IN2
10, 5, 4 // ENB, IN3, IN4
);Many motors need a minimum power level to overcome static friction.
controller.setMotorMinPWM(90);Typical values:
| Robot Type | Recommended Value |
|---|---|
| Small robot | 70–90 |
| Medium robot | 90–110 |
| Heavy robot | 110–130 |
If motors buzz but do not move → increase this value.
#include <Controller.h>
Controller controller("RobotAP", "12345678");
void setup() {
Serial.begin(115200);
controller.configureL298N(9,7,6, 10,5,4);
controller.setMotorMinPWM(90);
controller.setFailsafeTimeoutMs(1000);
controller.beginAP(true);
}
void loop() {
controller.update();
}The failsafe ensures the robot stops if:
- The joystick is released
- The connection drops
- The browser closes
- No drive command is received within a timeout
Set timeout:
controller.setFailsafeTimeoutMs(1200);- 800–1500 ms
Smaller value → more responsive but can feel jerky
Larger value → smoother but robot continues longer if connection is lost
You can register custom buttons in the web interface.
void onPress() {
Serial.println("Button pressed!");
}
void setup() {
controller.registerButton("Press Me", onPress);
}Buttons are momentary (trigger once per press).
If you want to handle motor logic yourself:
void onDrive(int8_t left, int8_t right) {
Serial.print("Left: ");
Serial.print(left);
Serial.print(" Right: ");
Serial.println(right);
}
void setup() {
controller.registerDriveCallback(onDrive);
controller.beginAP(true);
}left and right range from -100 to 100.
The onboard LED can show system states.
Enable it:
controller.enableStatusLED(LED_BUILTIN);| Pattern | Meaning |
|---|---|
| Fast blink | Booting |
| Slow blink | AP ready |
| Solid ON | Client connected |
| Rapid blink | Error |
| Double blink | Failsafe active |
Enable debug:
controller.beginAP(true);Debug prints:
- WiFi scan results
- Drive commands
- Motor values
Disable:
controller.beginAP(false);If the robot is powered by battery and you connect USB to your computer:
Otherwise, the board may soft-reboot or behave unexpectedly.
- Make sure you're using
http:// - Confirm you are connected to the robot WiFi
- Try
http://10.0.0.2
Increase failsafe timeout:
controller.setFailsafeTimeoutMs(1500);Increase minimum PWM:
controller.setMotorMinPWM(110);- Increase failsafe timeout slightly
- Reduce minimum PWM
- Check battery voltage
- Ensure good WiFi signal
Compile:
pio run
Upload:
platformio run -t upload
Run tests:
pio test -e uno_r4_wifi
WL_IDLE_STATUS = 0
WL_NO_SSID_AVAIL = 1
WL_SCAN_COMPLETED = 2
WL_CONNECTED = 3
WL_CONNECT_FAILED = 4
WL_CONNECTION_LOST = 5
WL_DISCONNECTED = 6
WL_AP_LISTENING = 7
WL_AP_CONNECTED = 8
This library was built to:
- Replace fragile hardware joystick controllers
- Provide a customizable wireless interface
- Ensure safety through built-in failsafe
- Allow teams to easily extend functionality
- Use the Uno R4 WiFi’s ESP32-S3 module
Enjoy building 🚀