Hi all, kinda new to all this. I have code to make led lights flash (string lights) on and off. However, I'd like it to flash for a set time, then stay on until power is removed. What code would I need to add to my script? Thanks in advance.
Code is:
void setup(){
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
}
void loop(){
//show colour 1;
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
delay(500); //wait half a second
//show colour 2:
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
delay(500); //wait half a second
//any more pattern or changes here...
}
A simple approach would be to use a for loop in your setup() function to turn the lights on and off a number of times and then turn them on.
And do nothing in the loop() function.
Simple but kinda brain dead, as there would be no way to say "do that again" other than to reset or power cycle the board.
The Hello World "blink" sketch blinks forever, but the same turn on, delay, turn off, delay pattern can be placed in a for loop, so all you'd have to know about if you don't already is a way to use a for loop to do something N times.
Do you know the Iced Tea guy? He can tell you all about it. I prefer to read, just can't sit still for 30 minutes to get 4 minutes of content, but ppl like him:
No matter, but if the OP had watched that video, or googled as I suggested, she might have been able to code this herself and she might have learned something.