Start up the Arduino software and open the Blink example sketch, as you did in Lesson #1

Then buckle up because you're going to take a journey into the heart of Blink!

The sketch itself is in the Sketch Writing/Text Input area of the Arduino software, which you may recall from the previous lesson:

Sketches are written in text, just like an essay, recipe, love letter or other document. When you select Compile/Verify from the menu, the Arduino software looks over the document and translates it to Arduino-machine-language - which is not human-readable but is easy for the Arduino to understand.

Sketches themselves are written in C and/or C++, which is a programming language that is very popular and powerful. It takes a bit of getting used to but we will go through these examples slowly.

Other languages you may have heard of include Scratch, BASIC, Swift, JavaScript, Python, or LOGO. (Part of inventing a new language is coming up with a cool and memorable name)

Let's peel off the text only from the Arduino IDE, so we can focus on the code itself:

  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at

  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second

Notice that some of the text has different coloring and shading! These visual hints will help a lot when reading and understanding a sketch

Lets take our first small step and look at the first chunk of text at the top....

This guide was first published on Sep 02, 2016. It was last updated on Sep 02, 2016.

This page (The Parts of a Sketch) was last updated on Sep 01, 2016.

Text editor powered by tinymce.