About a year ago, I wanted to improve my Arduino skills and decided to create a car model guided directly from my smartphone via Bluetooth. I didn't want to use a pre-built application but a new one created by myself (here for the curious ones).
The Bluetooth controller sends a signal every 50 milliseconds that contains the joypad current status in the app: the angle of the cursor and the strenght of the signal (in percentage). Arduino has to decode this data from the string received through the Bluetooth communication and to distribute the power between the left and the right motor.
This is how the joypad cursor should work with the L-R DC motors:
As we can see from the electronic schema for the project, as fundamental component I've used the L293D, with that I allowed me to have external power (up to 4.5 volt from 4 AAA batteries) for the motors and 9 volts for the arduino power supply and to control separately the direction and the power of each of the motors.
This is the flow followed by the code of the project:
After the Bluetooth Serial device setup, Arduino starts searching for commands and for each command it calculates the angle and the strength. After that it calculates the maximum speed allowed by the bluetooth command and implements the power distribuition on the 0-255 scale as the first image explains.
Comments