My student and I cannot debug his program. He wants certain color Led lights to turn depending upon the amount of movement of the accelerometer but they do not light up when he moves the accelerometer. Can anyone help with this one?
A few things … In this program, the three functions are only being called once. So, the first time, they are called, the lights turn green, but since they aren’t ever called again, even though movement gets larger than 10 and then 20, the code to change the colors doesn’t run.
Also, on line 21 (or so), I believe you need to use && instead of , (AND)…
else if ((movement < 20) && (movement >= 10)) {
Once I fixed that and also added function calls into the accelerometer function so the LEDOutput and the soundOutput run more than once, the led lights started working.
Good luck!
Mike
I also added else to a few of the conditional statements (but it may not be needed). Here’s a link to the code that appears to be working for me.
Mike
Michael,
Thank you, once again!