Floating Lights with Arduino
Floating Lights with Arduino

Floating Lights with Arduino

8 LEDs were used in this application. If desired, 5 more LEDs can be used.
8 of the digital output pins (13,12,11,10,9,8,7,6) are set as output. It is set to pinModeoutput as in the previous examples.

With the help of the for loop, code clutter is avoided. We can change the effects of the leds by changing the number of these cycles.
Arduino Codes:
void setup()
{
  // Red leds -------------------
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  //blue leds----------------------
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);  //yellow led <------------
  pinMode(6, OUTPUT);  //green led  <-----------
   }
 
void loop()
{
  for(int i=6;i<14;i++)  {
    digitalWrite(i,HIGH); delay(20);digitalWrite(i,LOW);
    }
    for(int i=14;i>5;i--)  {
    digitalWrite(i,HIGH); delay(20);digitalWrite(i,LOW);
    }  
}