Go Down

Topic: Arcade Cabinet LED Animation (Read 1 time) previous topic - next topic

granter

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);
}
}
}

robtillaart

#1
Mar 05, 2011, 08:54 am Last Edit: Mar 05, 2011, 08:57 am by robtillaart Reason: 1
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 :)

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

granter

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.

granter

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

granter


Go Up