typestar

The sketch shape in Arduino

Blink: the hello world of hardware, in two functions.

// Every sketch is two functions: setup runs once, loop forever.
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}

How it works

  1. setup() runs once at power-on; loop() repeats forever.
  2. pinMode claims the pin; digitalWrite drives it HIGH and LOW.
  3. delay(500) holds each state for half a second.

Keywords and builtins used here

The run, in numbers

Lines
11
Characters to type
217
Tokens
44
Three-star pace
75 tpm

At the three-star pace of 75 tokens a minute, this run takes about 35 seconds.

Type this snippet

Step 1 of 3 in The sketch, step 1 of 27 in Language basics.

Next →