Saturday, 12 July 2014

RC Car - Part 2

If you haven't read it, you might want to read the first part of this weekend project.

I finally got the time to continue my RC Car project. This time my goal was to control the car from my laptop. Continuing from my last design, I tried to communicate with the car via radio frequency using nRF24 module. This was an easy task as we already made a chat app via radio frequency using the same module. I used an Arduino Nano to communicate serially with my laptop, then attached an nRF24 module to it.
Arduino Nano + nRF24 module
Then for the receiver (the car), I used Arduino Pro Mini (much cheaper than Arduino Nano) + nRF24 module. Then I attached it to an H Bridge module, L298N to control the motor so it can go forward and backward. H Bridge is a module that allows you to control high current voltage in or out of the circuit. For our project, it allowed me to control the motor to rotate clockwise or counterclockwise and allowed me to power the motor (which wasn't sufficiently powered via Arduino). Finally, I connected the H Bridge with the Arduino Pro Mini and two motors.

Oh! Almost forgot the battery. I connected them with the H Bridge since we needed its high current to flow to our motors.

From left to right: nRF24 module, Arduino Pro Mini, H Bridge, awesome chassis, and LiPo battery
The last piece was the code. From my Arduino Nano (the one connected with my laptop), I read 4 serial input: w, s, a, d (I know, I'm a gamer). Then I mapped each input to binary output, then sent it to the Arduino Pro Mini. The Arduino Pro Mini would then control the H Bridge and consequently control the motors.

InputWhat It DoesOutput
wForward1010
sBackward0101
aTurn Left0110
dTurn Right1001
Anything elseStop0000

Finally, not so awesome demo:
video

My right (or left?) motor was broken after 2nd attempt so it wasn't spinning at all.

The project was depressing, but ultimately fun. If I were to continue this project, I would try throttling the speed of each motors for more stable movement and trying more sophisticated transport layer, Bluetooth. For now I'm just content that my design worked :)