hi to all
i am new in programming. i write a code in c. but problem how to multiple led blink in c
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
* Blink - makes a single LED blink on and off
*/
void setup() {
pinMode(13, OUTPUT); // pin 13 - change value if you have LED on diff pin
}
void loop() {
digitalWrite(13, HIGH); // set pin 13 to high voltage, turning LED on
delay(1000); // wait 1000 milliseconds, or one second.
digitalWrite(13, LOW); // set pin 13 to low voltage, or zero. LED off.
delay(1000); //wait one second before starting the loop again.
The key is that the loop runs at a high rate. Each time through the loop, you decide which LEDs (if any) must be toggled.
1 2 3 4 5 6
void loop() {
if (time to toggle LED1) toggleLED1();
if (time to toggle LED2) toggleLED2();
...
delay(50); // Delay 50 ms
};
You should probably encode whether to toggle the LEDs in some data. Maybe there's an array associated with each LED that says whether it goes on or off: char arr1[20] = "01001100011100001111";
Then each time through the loop, in increment a counter (reset to zero when you hit the end of the array) and turn the LED on or off depending on whether the array value is '0' or '1'.