pixelbar is currently

← back to the workshops

Blinking LED

Requirements

Project Image

sketch

Project code

/*
  Blink

  Switching a LED on and off
*/

// integer variable led is declared
int led = 2;

// the setup() method is executed only once
void setup() {
  // the led PIN is declared as digital output
  pinMode(led, OUTPUT);
}

// the loop() method is repeated
void loop() {
  // switching on the led
  digitalWrite(led, HIGH);

  // stopping the program for 1000 milliseconds
  delay(1000);

  // switching off the led
  digitalWrite(led, LOW);

  // stopping the program for 1000 milliseconds
  delay(1000);
}