Blink LEDs Without Delay

How to blink leds without delay using an Arduino nano.

Use for car directional lights, signs, warning lights.

 

Code

/* Blinks Leds without delay
Two leds blink. You may add additional leds if you wish.
Use for car directional lights, signs, warning lights.
Code by Gary Grani 17 August 2021
Details, video and wiring diagrams at Blink LEDs without delay
You may use this code freely and make changes so long as these credits remain in place and remain unchanged.
*/

#define led 8 // connect led 1 to this pin
#defube led2 9 // connect led 2 to this pin
int x = 1;
unsigned long t1=0;
unsigned long t2;
void setup() {

pinMode(led,OUTPUT);
digitalWrite(led,1);
digitalWrite(led2,1);
//Serial.begin(9600);
}

void loop() {
t2=millis();
if (t2-t1 >=1500){ // change this to set your desired blink frequency
x=1-x;
t1=millis();
digitalWrite(led,x);
digitalWrite(led2,x);
// Serial.print(t1);
}}

 

 

Tell others about this information by using one of these services. Thank you for the support.
Scroll to top