Hi Arduino Community,
I'm new here and having great fun learning Arduino myself during lockdown (Tinkercad is a brilliant tool).
I have completed basic code to set various LEDs at different blinking patterns with the delay function in a loop.
Next I would like to run these different blinking pattern LEDs at the same time.
I have trawled this forum and there are lots of mentions of millis and state functions along with plenty of previous examples of code including 'SeveralThingsAtTheSameTime'.
I'm still very knew so I don't quite fully understand everything just yet to be able to copy and write myself.
I tried running the above code but kept getting errors with servos and buttons I really don't want to get messed up with with yet.
Just trying to 'keep-it-simple-stupid' as I learn my way through it all.
I understand the millis function is probably what I need to run these LEDs simultaneously and put the delay code in the bin?
Below is just an example of the loop code LED blinking I was able to do.
(to all you hardcore-pro-coders, I know this code is probably not very handsome but I'm learning!).
How would I run these LEDs simultaneously? and let it just run again and again and again.
No buttons, no messing, just simple-stupid so I can get the hang of it!
Thanks!
int red=13;
int redTime=250;
int redBlink=5;
int green=12;
int greenTime=700;
int greenBlink=3;
int yellow=11;
int yellowTime=500;
int white=10;
int whiteTime=1500;
int whiteBlink=6;
int j;
void setup()
{
pinMode(red,OUTPUT);
pinMode(green,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(white,OUTPUT);
}
void loop() {
for(j=1;j<=redBlink;j=j+1){
digitalWrite(red,HIGH);
delay(redTime);
digitalWrite(red,LOW);
delay(redTime);
}
for(j=1;j<=greenBlink;j=j+1){
digitalWrite(green,HIGH);
delay(greenTime);
digitalWrite(green,LOW);
delay(greenTime);
}
digitalWrite(yellow,HIGH);
delay(yellowTime);
digitalWrite(yellow,LOW);
delay(yellowTime);
digitalWrite(yellow,HIGH);
delay(yellowTime);
digitalWrite(yellow,LOW);
digitalWrite(white,HIGH);
delay(whiteTime);
digitalWrite(white,LOW);
delay(whiteTime);
for(j=1;j<=whiteBlink;j=j+1){
digitalWrite(white,HIGH);
delay(600);
digitalWrite(white,LOW);
delay(600);
}
}