Skip to content

Instantly share code, notes, and snippets.

@e-Gizmo
Created April 2, 2018 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-Gizmo/7b426c706778fd0a7c7821418fbbe77a to your computer and use it in GitHub Desktop.
Save e-Gizmo/7b426c706778fd0a7c7821418fbbe77a to your computer and use it in GitHub Desktop.
////////////////////////////////////////////////
// //
// ON OFF SEQUENCE //
// //
// This serves as a sample program for //
// an LED monitor showing a on off sequence. //
// //
// //
// Codes by: //
// eGizmo Mechatronix Central //
// Taft, Manila, Philippines //
// http://www.egizmo.net //
// April 11, 2013 //
////////////////////////////////////////////////
int DEL1 = 100; // Adjust this delay for separating functions
int DEL2 = 100; // Adjust this delay for individual delay of turning on/off the LEDs
int LED_NUMBER[] = {4,5,6,7,8,9,10,11};
void setup()
{
for(int i =0; i<=7; i++)
{
pinMode(LED_NUMBER[i],OUTPUT); // Sets all the LED pins as OUTPUT
}
}
void loop()
{
ASCENDONOFF();
delay(DEL1);
DESCENDONOFF();
delay(DEL1);
}
// Turns on and off the LEDs in ascending order
void ASCENDONOFF()
{
for(int i=0; i<=7; i++)
{
digitalWrite(LED_NUMBER[i],HIGH); // Turns on the LEDs
delay(DEL2);
digitalWrite(LED_NUMBER[i],LOW); // Turns off the LEDs
delay(DEL2);
}
}
// Turns on and off the LEDs in descending order
void DESCENDONOFF()
{
for(int i=7; i>=0; i--)
{
digitalWrite(LED_NUMBER[i],HIGH); // Turns on the LEDs
delay(DEL2);
digitalWrite(LED_NUMBER[i],LOW); // Turns off the LEDs
delay(DEL2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment