Arduino 4WD Mecanum controlled by an Android app using an Arduino Mega 2560, a L293D motor shield and a HC-05 Bluetooth Module.
The APK of the application can be downloaded here APK.
-
Switch on the Arduino and the HC-05 Bluetooth module.
-
On your smartphone, scan the available Bluetooth devices and associate with the HC-05 Bluetooth module with the default password "1234".
-
Install and start the application. Link of the APK
-
Select the HC-05 Bluetooth module.
- Have fun!
The application contains:
- A joystrick and two buttons to control the robot
- A seekbar to control speed
- A switch in the top left to switch to night mode
- A button to disconnect from the robot
Don't forget to cross RX and TX!
The frames are in the following form:
sxxyyy
- "s" for "start" allows us to know when a frame starts
- "xx" is the value of the movement performed by the user. For example, if the joystick is pushed forward to go straight, the movement will be "03".
- "yyy" is the value of the speed chosen by the user. For example, if the speed is at maximum, the value will be "255".
For this example, the final result is as follows: s03255
To summarize: 1 header letter + two movement digits + three speed digits
-
Retrieve the data received by Bluetooth and separate them if necessary
receivedData = Serial1.readStringUntil('s'); // split received data into frames delimited by a 's'
move = receivedData.substring(0,2).toInt(); // split two first digits to get movement value
speed = receivedData.substring(2,5).toInt(); // split three last digits to get speed value -
Perform the processing according to the data received.
For example:
moveRobot(move, speed);
MIT License. See the LICENSE file for details.
Feel free to contact me if I can optimize the code or if there is an errorr. I'm a newbie. Thank you!