Step 3: C-programming
The code is written in C as I didn't care for learning the "easier" processing language which arduino is based on. I wrote the SPI and rf tranceiver interface myself for the learning-experience, but borrowed the i2c assembler-code from avrfreaks.net. The shiftbright interface is bitbanged in C-code.
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;