Step 3: How it Works: Receiver

Picture of How it Works: Receiver
Once the transmitter goes high or low, so does the receiver's data line, so to send data packets all you have to know is the distance between the pulses, and where the data packet starts.  When the RX line goes high, the Arduino's interrupt is triggered, and it starts reading data. It waits 0.5 ms, checks if it's high or low, waits again, and so on; high = 1, low =0, like before. The bytes are sent in descending order, so each bit carries half the value of the previous one. If it reads a start code, it will continue reading data; otherwise, it quits. After it has stored all the new data, it quits the interrupt and spends the next 10ms updating and running the servo and motors until the next packet arrives.

You can see in the code that every time the Arduino successfully recognizes the start code, it blinks the LED that comes pre-installed on pin 13. This makes it easy to see it your radio is transmitting properly -- the white light should be flickering on pretty much continuously.

         The Arduino scales the motor values to be higher the further the potentiometer is from 128, with a maximum amplitude at 0 and 255 (raw values). The direction (reverse / forward) is determined by the two digital inputs that go into the H-bridges ( the motor driver circuits -- I used the design from Mark Tilden's site). Pull one side high, it goes reverse, and the other side makes it go forward. That might sound mysterious, but look at the schematic with all the transistors laid out nicely and it'll make sense. The H-bridges I built can be seen in the picture.

Anyway, the motors draw a relatively large amount of current, so you can't power them directly from the 7805 -- they draw from the 7.4V battery through transistors. The servo and radio, however, do run off the voltage regulator. You can see all of the receiver parts connected together above. It is a bit of a mess, in the name of reducing weight.