Step 3: C-programming
One problem which I encountered was small irradic variations in accelerometer-output, this made the led's flicker alot. I solved this with a software low-pass filter. A moving weighted average on the accelerometer-values.
The rf-tranceiver support hardware crc and ack with auto-retransmit, but for this project the realtime, smooth updating of the leds was more important. Every packet with accelerometer values does not need to arrive intact at the receiver, as long as corrupted packets is discarded. I had no problems with lost RF packets within 20 meters line of sight. But further away the link became unstable, and the leds did not update continously.
The main loop of the transmitter in pseudo-code:
Values = abs(get x,y,z accelerometer values());
The main loop of the receiver in pseudo-code:
newValues = blocking_receiveRF());
rgbValues = rgbValues + 0.2*(newValues-rgbValues);
write rgbValues to shiftbrigth;