Arduino: Multi Style Blinking LED

This entry is part 3 of 9 in the series All About Arduino

In this program we will learn to blink the single LED on Arduino UNO board in different styles.

Use the same procedure to upload this program into your Arduino development board. The following program is fully tested and works fine with Arduino UNO dev. board.

Multi Style Blinking Code

Copy paste the following code into your New File created in Arduino Software. Then save the project. Connect your dev. board to the PC and then upload this program into your Arduino UNO kit.

/*
* Alternate styles of blinking LED
* Date: 24.11.2018
* Vidyasagar Academy, Akola 
* www.vsagar.org
*/

int LED=13; // the variable LED assigned to pin-13
int i; // another variable to store styles of blinking

void setup() // here we define any pin as input/output pin
{
pinMode(LED, OUTPUT); // defined pin-13 as output pin
}

void loop() // infinite loop
{
// here the LED blinks 5 time for 100ms each
for(i=0;i<5;i++) // 'for' loop to define number of blinks of LED
{
digitalWrite(LED, HIGH); // LED is on
delay(100); // wait for 100ms 
digitalWrite(LED, LOW); // LED is off
delay(100); // wait for 1 second
}

digitalWrite(LED, LOW); // LED is off
delay(1000); // wait for 1 second

// here the LED blinks 7 time for 1s each
for(i=0;i<7;i++) // 'for' loop to define number of blinks of LED
{
digitalWrite(LED, HIGH); // LED is on
delay(1000); // wait for 100ms 
digitalWrite(LED, LOW); // LED is off
delay(1000); // wait for 1 second
}

digitalWrite(LED, LOW); // LED is off
delay(1000); // wait for 1 second

// here the LED blinks 4 time 100ms ON, 1sec OFF
for(i=0;i<4;i++) // 'for' loop to define number of blinks of LED
{
digitalWrite(LED, HIGH); // LED is on
delay(100); // wait for 100ms 
digitalWrite(LED, LOW); // LED is off
delay(1000); // wait for 1 second
}
}
Series Navigation<< Arduino: Fading LEDArduino UNO Single Blinking LED >>