Skip to content

About

Example code for the MiniBot v3

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

LoR Core V3 MiniBot Bluetooth Gamepad Example

Control a MiniBot with a Bluetooth gamepad using the Lord of Robots LoR Core V3. This Arduino sketch provides tank-drive control, motor output configuration, battery warnings, and onboard LED status feedback.

Tested board selection: esp32_bluepad32 → ESP32 Dev Module.

What you need

  • A LoR Core V3 and MiniBot hardware with compatible motor controllers.
  • A USB data cable to connect the LoR Core to your computer.
  • A Bluetooth gamepad supported by Bluepad32.
  • Arduino IDE.

Dependencies

Dependency Version / installation Purpose
Bluepad32 Included in the esp32_bluepad32 board package Bluetooth gamepad support
ESP32Servo 3.0.7 through Library Manager Motor and servo PWM outputs
FastLED Latest through Library Manager Onboard addressable LEDs

Keep ESP32Servo at version 3.0.7 to avoid timing regressions. Select that version explicitly during installation and keep it when the IDE offers library updates.

1. Set up Arduino IDE

Add the board package URLs

  1. Open Arduino IDE.
  2. Go to File → Preferences → Additional Boards Manager URLs.
  3. Open the URL list editor and add each URL on its own line. Keep any URLs already in your list:
https://dl.espressif.com/dl/package_esp32_index.json
https://raw.githubusercontent.com/ricardoquesada/esp32-arduino-lib-builder/master/bluepad32_files/package_esp32_bluepad32_index.json
  1. Click OK to save.

Install the board packages

Open Tools → Board → Boards Manager (or the Boards Manager sidebar in Arduino IDE 2), then install both:

  • esp32 by Espressif Systems.
  • esp32_bluepad32 by Ricardo Quesada.

The Bluepad32 package may appear as ESP32 + Bluepad32 in the IDE. It supplies the Bluetooth stack and Bluepad32.h; there is no separate Bluepad32 Library Manager installation for this setup.

Install the libraries

Open Sketch → Include Library → Manage Libraries:

  1. Search for FastLED and install the latest version.
  2. Search for ESP32Servo, select 3.0.7 from its version dropdown, and click Install.

Select the board

Under Tools → Board, choose esp32_bluepad32 → ESP32 Dev Module. Depending on the package version, the group may be labeled ESP32 + Bluepad32 Arduino.

Make sure the selected ESP32 Dev Module belongs to the Bluepad32 package. The standard esp32 → ESP32 Dev Module selection does not provide this sketch's Bluepad32 environment.

For more detail, see the Bluepad32 Arduino setup guide.

2. Download and open the sketch

  1. On this repository's GitHub page, choose Code → Download ZIP, then extract the archive.
  2. Rename the extracted folder to LoR_Core_V3_MiniBot_Example so it matches the sketch filename.
  3. In Arduino IDE, open File → Open and select LoR_Core_V3_MiniBot_Example.ino.

Keep the sketch inside its matching folder:

LoR_Core_V3_MiniBot_Example/
└── LoR_Core_V3_MiniBot_Example.ino

3. Upload to the LoR Core V3

  1. Connect the LoR Core to your computer with a USB data cable.
  2. Confirm the board is set to esp32_bluepad32 → ESP32 Dev Module.
  3. Under Tools → Port, select the LoR Core's serial port. On Windows this appears as a COM port; unplugging and reconnecting the USB cable can help identify it.
  4. Click Verify (checkmark) to compile the sketch.
  5. Click Upload (right arrow) and wait for completion. The first compile and upload may take 3–5 minutes, depending on your computer.
  6. Open Tools → Serial Monitor, select 115200 baud, and press RST to view startup messages.

Uploads normally enter boot mode automatically. If the IDE stays at Connecting... or cannot connect:

  1. Press and hold BOOT.
  2. While holding BOOT, press and release RST.
  3. Release BOOT, then retry Upload.
  4. Press RST after the upload if the sketch does not start automatically.

If no serial port appears, try another data cable or USB port. On Windows, check Device Manager → Ports (COM & LPT). Install the CH340 USB serial driver from WCH if needed, then reconnect the board.

4. Pair your Bluetooth gamepad

  1. Power on the LoR Core V3.
  2. Press and hold User Button A + User Button D.
  3. While holding both buttons, press and release RST.
  4. When the onboard LEDs flash blue and white, release A and D.
  5. Put your gamepad into Bluetooth pairing mode using its manufacturer's button sequence.
  6. Wait for a green flash to confirm connection. The sketch then leaves pairing mode automatically.

Entering pairing mode clears the previously saved Bluetooth keys. After successful pairing, the gamepad should reconnect on future power cycles without repeating these steps.

Driving the MiniBot

The example configures all 12 output slots as N20Plus and uses tank-drive controls:

Gamepad input Outputs
Right joystick Y axis Slots 1–6
Left joystick Y axis Slots 7–12

The onboard user switch changes the joystick direction mapping. A deadband of 100 removes small stick movements near center, and joystick values are mapped to motor speeds from -100 to 100, where 0 is stop.

When no gamepad is connected, the main loop writes a neutral command (90) to every output slot. If you adapt the example for positional servos, this also centers those servos.

LED status

LED appearance Meaning
Icy blue Waiting for a gamepad connection
Flashing blue and white Pairing mode
Green flash Gamepad connected
Rainbow animation Receiving gamepad control data
Red Disconnection event or battery warning; check Serial Monitor for details

The sketch also briefly displays startup diagnostic colors. Serial Monitor at 115200 baud provides the reset reason, battery readings, and joystick values.

Customizing the example

Motor types and commands

Set each output's device type in setup() using ConfigureMotorOutput(slot, type). The type determines the PWM frequency, pulse range, and whether speed or position commands are accepted.

Function Input Use
MotorSpeed_Set(slot, speed) -100 to 100; 0 stops N20Plus, continuous-rotation servos, or compatible speed controllers
MotorPosition_Set(slot, angle) 0 to 180 degrees Standard positional servos

For example, to use slot 12 for a positional servo:

// In setup(), replace ConfigureMotorOutput(12, N20Plus):
ConfigureMotorOutput(12, STD_SERVO);

// In the connected-gamepad branch of loop(), replace MotorSpeed_Set(12, MappedLeft):
MotorPosition_Set(12, map(myController->throttle(), 0, 1023, 0, 180));

Choose the motor type and pulse range appropriate for your connected device. Speed and position functions ignore slots configured for the other command type.

Gamepad inputs

myController provides live Bluepad32 input data. Read it inside the existing connected-gamepad branch of loop().

Input methods Data
axisX(), axisY() Left joystick, approximately -512 to 512
axisRX(), axisRY() Right joystick, approximately -512 to 512
throttle(), brake() Triggers, 0 to 1023
buttons(), dpad(), miscButtons() Button bitmasks
gyroX(), gyroY(), gyroZ() Gyroscope readings, if supported
accelX(), accelY(), accelZ() Accelerometer readings, if supported
battery() Gamepad battery level, if supported

Battery monitoring

GamePad_BatteryMonitor() checks the controller battery roughly once per second. A reported value of 0 means unknown; values 1–64 trigger a low-battery warning, 65–128 set the gamepad LED yellow, and values above 128 set it green. LED and rumble feedback depend on controller support.

LoRcore_BatteryMonitor() estimates robot input voltage using VIN_SENSE, VOLT_SLOPE, and VOLT_OFFSET. The current call in loop() is:

LoRcore_BatteryMonitor(1, 3.0);

This sets a warning threshold of 1 cell × 3.0 V = 3.0 V. Adjust the cell count and per-cell threshold to match your battery. Low voltage produces serial and red LED warnings; this function does not shut off the motors or disconnect the battery.

Troubleshooting

Problem What to check
Bluepad32.h is missing Install the Bluepad32 board package and select its ESP32 Dev Module board.
ESP32Servo.h or FastLED.h is missing Install the library through Library Manager; use ESP32Servo 3.0.7.
PWM / LEDC errors or unexpected motor timing Confirm ESP32Servo 3.0.7 and the Bluepad32 board selection.
No port or upload connection fails Check the USB data cable, serial port, CH340 driver, and manual BOOT/RST sequence above. Close other programs using the serial port.
Serial Monitor output is unreadable Set the baud rate to 115200.
Gamepad will not connect Use a supported controller, charge it, and repeat the A + D pairing sequence.
Motors do not respond as expected Check power, output-slot wiring, configured motor types, user switch position, and gamepad connection.

About

Example code for the MiniBot v3

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages