Part of my crazy countdown timer is that I want to detect if someone is moving it, so I need to work with the accelerometer.
So I created a new app and made it tic-toc between 2 spokes on the star LEDs. This is mainly to show that the app is still running, in case it hangs or something. It helps when debugging. This part was a continuation of the basic_led sample I had earlier, and simply turns on more LEDs.
Then I copied the accelerometer code from the demo, and pruned it as much as possible to take out all the modes and options that I don't want. I left it detecting just motion of any sort. At first it was a little (a lot) too sensitive - knocking lightly on the counter top beside it set it off. So I added a #define named "SENSITIVITY" at the top of the file to adjust sensitivity easily. Now it takes a drop of from about 5 mm to set it off (lifting just the far side of the board, opposite the star LEDs), or a shake.
I added some code to make the whole star flash when motion was detected, and it seems to all work quite nicely.
Attached is the code. You don't need anything more than the XL_star board to run this demo.
As usual, create a new project from scratch (following the docs), then replace the content of main.c with the content of the attached file.
Then you'll need to copy iic.c, iic.h, and mma845x.h from the demo into the source folder of your new project.
Then back in CodeWarrior right-click on sources and "add files" and choose iic.c from your project folder.
Build it and run it, and you'll see it alternate between lighting up one spoke, then the next, then back to the first.
If you move the board too much, the whole star will flash (ie, motion was detected).