Arcade Cabinet LED Animation

Hi everyone, trying to animate about 60 LEDs I inlayed in a Pinball Cabinet that I am making, you can see more about the build of the cabinet at retrocadespot.blogspot.com.

Here is a picture of the image side where I have inlayed the LEDs.

I have LEDs in each of the robots numbers on her leg, and some in her eyes, and in the stars. I'd like to have the numbers increment 1 by 1 and then flash. At the same time this is going on I'd like to twinkle the stars (fade LEDs on and off) and do some animations on her eye and the top of her head where I have some LEDs as well. I also have LEDs on the girl standing in the backbox, specifically her heart, and eyes.

Below is my code so far, I basically just have a loop in which I use a for loop to increment the numbers, and then flash them 10 times. My problem is if I want to run this loop while sparking stars, I don't think I can. Maybe I have to do away with for loops and just set each LED one by one to try and create the effect I want?

int rightlegLED[8]={25,26,27,28,29,30,31,32};
int backboxeyeLED[4]={21,22,23,24};
//Initial Stuff
void setup ()
{
//Set the LED pins to be an OUTPUT
for(int i=0;i<8;i++)
{
pinMode(rightlegLED*,OUTPUT);*
}
for(int i=0;i<4;i++)
{
pinMode(backboxeyeLED*,OUTPUT);*
}
}
void backboxeyes ()
{
for(int i=0;i<4;i++)
{
digitalWrite(rightlegLED*,HIGH);*
}
}
void loop ()
{
for(int i=0;i<8;i++)
{
digitalWrite(rightlegLED*,HIGH);*
delay(5000);
}
for(int i=0;i<10;i++)
{
for(int i=0;i<8;i++)
{
digitalWrite(rightlegLED*,LOW);*
delay(1000);
}
for(int i=0;i<8;i++)
{
digitalWrite(rightlegLED*,HIGH);*
delay(1000);
}
}
}

Please use # button for code

Check the famous - http://arduino.cc/en/Tutorial/BlinkWithoutDelay - tutorial how to blink LED's without using delay and keep enough time to do other things you want to do.

And you may use - http://www.arduino.cc/en/Reference/Random - for the timing to get a bit more unpredictable twinkling in her bionic eyes :slight_smile:

Thanks for your help, that makes sense, I guess if I set a few variables I can store the state of the LEDs and as I go through the loop based on the time they were last turned on use if statements to toggle or not toggle them.

I'll give it a try tonight and see if I can get something working. This is a little trickier than I thought it would be, I hadn't thought about the complexity of trying to in affect control 3 different animations that need to execute in parallel at the same time, all within the same loop.

Someone on another forum I belong to for making pinball machines came up wiht something that I might be able to adapt, have a look here if you are curious

http://www.hyperspin-fe.com/forum/showthread.php?t=11780&page=2

Uses a timer, to compare against and turn on off LEDs accordingly

Here's a test video of just the LEDs running in a random pattern

Uses a timer, to compare against and turn on off LEDs accordingly

That is exactly the same advice give to you in reply number 1 by robtillaart.

Hi yes thanks everyone for the timer suggestions. Only challenge I've found with them is where you want to maybe use PWM and fade leds on and off it's hard to work with the timer setup but it can be done.
Here is a vid of the latest animation I have, just a first cut, need to speed up some things and slow some things down.

Let me know if you have any suggestions.

Video of gameplay and all LEDs including the 4 Crees I use so you can see more of the project