3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Wireless Accelerometer Controlled rgb-LED's

Step 3C-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:

initialize();

while(true){
Values = abs(get x,y,z accelerometer values());
RF_send(Values);
delay(20ms);
}

The main loop of the receiver in pseudo-code:

initialize();

while(true){
newValues = blocking_receiveRF());
rgbValues = rgbValues + 0.2*(newValues-rgbValues);
write rgbValues to shiftbrigth;
}
« Previous StepDownload PDFView All StepsNext Step »
1 comment
Oct 9, 2008. 1:07 PMcrizo says:
The "easier language" for arduino is actually c++ with some preprocessing. Your program would probably compile and run as-is.
Oct 11, 2008. 8:47 AMcrizo says:
I haven't been at it long, but I was very happy when I discovered this. It had been 5-6 years, and I was worried that my C/C++ was getting a little rusty. Once I started playing with the Arduino, I was able to jump right back into pointers, etc...

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
2
Author:Andlier