Monday, September 30, 2013

Remote Controlling the car

So the car can run and move, now to the fun stuff, to add a remote control to the Car.
First things first, what to use as a remote? I decided to use a Joystick BOB (break out board) module. Look at the picture, does it look familiar? It should, it's the same analogue Joystick you use in the PS/PS2/PS3 controllers. To connect it to the Arduino board it's very simple, the module has 5 pins which are (not in the correct order :)):
1. VCC
2. GND
3. X - Axis
4. Y - Axis
5. Swtich

The connections, well, the first two you know where they go. The X and Y axis goes to the analogue pins of the Arduino. The switch is optional, if you like to use it then connect it to whatever pin on the Arduino.

The X and Y axis are actually POT devices, so when tilting the joystick, the X will have a certain voltage from 0 - 5V corresponding to the tilt and the Y acts the same. 

Great, now the Joystick is connected and the Arduino can read the position of the Joystick, let's try make something run.

Still, the data needs to be sent wireless to the Toy Car. Again, cheap stuff. There are nice 433Mhz transmitter and 433Mhz receiver modules that can be used for this. These modules are really cheap, something like 1.25$ for both a transmitter and receiver.

The thing is on these cheap wireless modules is that they really don't do much.
The transmitter when the data pin goes to HIGH, starts sending a 433Mhz wave signal and that's it. When the pin goes LOW, it stops sending the wave signal.

The transmitter when receiving a wave signal on the 433Mhz band, it turns the data pin HIGH and when there is no signal, it turns it to LOW.

You can understand that these modules will not work out-of-the-box and require some software tuning code. Luckily, there is a nice Arduino library called VirtualWire that does all the fine work of CRC checks and synchronizing the transmission and receiver to a pre-configured baud rate. The library does not support multiple transmitters, or to be more clear a collision detection or avoidance mechanism (for wireless it's CA - Collision Avoidance). I'm not going to go deep into it, but I do have an idea on implementing it myself, but that will have to wait for the other 5 433Mhz module to arrive so I can do some tests.

The transmitter module and the receiver modules do not come with an antenna, so just for the purpose of the tests, I used an alligator clip as an antenna.



Great! Now let's connect everything together. The Joystick will be connected to the first Arduino board along with a transmitter module. It will read the values of the joystick and transmit them, nothing fancy.
The second Arduino will be connected to the Toy Car and the receiver module.

After a few tries from my son (my trustee QA :)) I finalized the correct calibrations, and the car worked nicely.

Here is a demo of my son testing the car:


The sound of glass braking at the end of the video was done by my daughter that dropped a glass by mistake in the kitchen, nothing serious :).

No comments:

Post a Comment