Flash LEDs with Arduino
Flash LEDs with Arduino

Flash LEDs with Arduino

AliExpress WW
AliExpress WW
In this application, we will flash blue and red LEDs used in ambulances, police vehicles and other vehicles.
Three red LEDs are connected to digital outputs. (13,12,11 pins)
Blue leds are also connected to digital outputs. (10,9,0 pins)
As we will remember from the previous examples, we can light the red and blue leds as we want with digitalWrite commands.
Arduino codes are below:
void setup()
{
  // Red leds -------------------
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  //blue leds----------------------
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
 }
 
void loop()
{
  //RED LEDS
  digitalWrite(13, HIGH);     digitalWrite(12, HIGH);    digitalWrite(11, HIGH);  delay(20);
  digitalWrite(13, LOW);      digitalWrite(12, LOW);     digitalWrite(11, LOW);  delay(40);
   digitalWrite(13, HIGH);     digitalWrite(12, HIGH);    digitalWrite(11, HIGH);  delay(20);
  digitalWrite(13, LOW);      digitalWrite(12, LOW);     digitalWrite(11, LOW);  delay(40);
  digitalWrite(13, HIGH);     digitalWrite(12, HIGH);    digitalWrite(11, HIGH);  delay(20);
  digitalWrite(13, LOW);      digitalWrite(12, LOW);     digitalWrite(11, LOW);  delay(40);
 
//BLUE LEDS-----------------
   digitalWrite(10, HIGH);    digitalWrite(9, HIGH);     digitalWrite(8, HIGH);  delay(100);
   digitalWrite(10, LOW);     digitalWrite(9, LOW);     digitalWrite(8, LOW);  delay(50);
}

100pcs/lot 5Colors*20PCS=5mm LED Diode Light Assorted Kit Green Blue Yellow Red COMPONENT DIY kit new original

AliExpress WW