Step 5: Make Your LED Blink!

Picture of Make Your LED Blink!
The Arduino library provides another useful little function called delay. The delay function takes in the length of the delay -- an int (integer) value in milliseconds.

Combining the delay function with the loop function allows us to create a blinking effect with the LED.

We will do this by setting a delay of 1 second (1000 milliseconds) between the LED being on (HIGH) and the LED being off (LOW).

We're going to use an int variable named DELAY so that we can change its value without having to type in numbers over and over everywhere.


// variables
int GREEN = 3;
int DELAY = 1000;

// basic functions
void setup()
  // setup LED modes
  // we're specifying that we're going to send information to this LED
  pinMode(GREEN, OUTPUT);

void loop()
  // High turns things on
  digitalWrite(GREEN, HIGH);
  // low turns things off
  digitalWrite(GREEN, LOW);