I took a bunch of changes from mchr3k, including comments and sorting out the code layout and fixing a couple of bugs. This now gives a very reliable connection between the car and the receiver – I’m seeing errors well below 1%.
I also wanted to be able to transmit a variable number of bytes (the original code always transmitted just one 16-bit integer) and have now got that coded up and working.
The full code with comments is available on github. See the code for a good description of how it all works – it is now commented fairly well. I hope that this will be a useful resource for other people trying to use RF modules with the ATTiny.
In the medium term I’m hoping to improve the library further to deal with interference better – right now the code just gives up if a transition occurs at an invalid time. I hope that if I do that I’ll be able to turn the bit rate up a bit.
It would also be nice to produce an interrupt driven receive side, to allow the receiver to avoid having to sit in the receive loop all the time. That’s not my priority right now though.