Little Bird Curriculum / code littlebird.com.au
_03_int.ino Arduino (C/C++) 12 lines · 2 views ✦ Open in English IDE Raw Download Embed view

Blink, rewritten to give pin 12 a name with the int command — clearer code, and you only change a pin in one place.

From the unit Crack the Code · activity PRP 2: Digital input — Button
int LED = 12;             // call pin 12 "LED" for the rest of this sketch

void setup() {
  pinMode(LED, OUTPUT);   // make the LED pin an output
}

void loop() {             // runs over and over again, forever
  digitalWrite(LED, HIGH);  // turn the LED on
  delay(1000);              // wait for one second
  digitalWrite(LED, LOW);   // turn the LED off
  delay(1000);              // wait for one second
}

Embed this snippet

As an iframe:

Or drop it inline with a script tag (injects the highlighted block where included):

Shared from Little Bird Electronics curriculum.

Copied to clipboard