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

 

 


We hope that you found the information in this page useful. The internet is all about getting and giving. And giving back is the best. Please donate $1 or more to aid us in our continuing quest to add to and polish the information in our site.


Scroll to top