Make a bouncing ball effect by making the LED start at one end, [ch699]drop[ch700] toward the other end, bounce back up, but to only go up 9 spaces, bounce, go up 8 spaces, then 7, then 6, etc. To give the effect it is a bouncing ball, getting bouncing up to a lower height on each bounce.
Base Source Code:
byte ledPin[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int ledDelay;
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
int potPin = 2;
if (currentLED == bounce) {direction = -1, bounce -= 1;}
if (currentLED == 0) {direction = 1;}
if (bounce == 0) {bounce = 9;}
added int bounce = 9 as a global int to start at 9
Having it decay each time the currentLed came up to the top. So my code is wrong and I'm sure I can't do one of those calculation like I have written them. Somebody please teach me the error of my way.
so im working on the same ASKmanual right now from eartshinedesign wich is now offline because he is working on a complete book.
anyhow the bouncing ball exercise.
just like the TS i came to the same conclusion for maken the light decade one led every time it hits 0 but it just doesnt work it keeps shifting to the 10 led.
if (currentled == bounce) // bounce is global variable set at 9 to start with
{
dir = -1;
bounce -= 1;
}
if (currentled == 0)
{
dir = 1;
}
if (bounce == 0)
{
bounce = 9;
}
}
so to be precise.
the led start ad led 10 than scrols back to led 0 when it hit zero bounce should be 8 so that it goes back up to led 9 an then back to zero when it hit zero again bounce has to become 8 so it scrols back to led 7 repeat this steps till it hits zero en the ball has no kinectic energy left. When 0 is reached bounce become 9 again and the process starts over and over and over again.
ok put bounce -= 1 under current == 0 instead of under currentled == bounce and now it works flawless ;D