First steps with the Arduino

So, having established that the board works, it's time to embark on learning how to program it.

Today I plugged in the board, and was pleasantly surprised to see that the test Blink program is still apparently running: the L LED is flashing on and off. It makes sense that the program uploaded last persists in the EEPROM, though that hasn't been revealed yet, in the tutorial kit's manual.

Starting off by opening the Arduino IDE, I'm again struck by the similarity to Processing, only now I've skipped ahead in the book, I now know that the interface is based on Processing.

Blank Arduino IDE

Also, I've decided to keep the tutorial code in a GitHub repo, at

Chapter 8

Chapter 8 is the first chapter asking the user to write their own program, and it recommends a couple of websites for background:

all of which are, unhelpfully for me, in German. The book is clearly translated from German (some und to and conversions are missed), and this is a dead giveaway. They'll not be much use.

The book also unhelpfully presents code in black against a dark grey background.


The first program to type in is essentially the same one we used to test the board. It makes the LED blink once per second. The IDE's code validation check is useful, as I'm used to writing Python and tend to miss off the semicolons.

The first blink program

The code validates OK, so I try to upload to the board, and here's where I hit my first problem:

[Arduino: 1.7.7 (Mac OS X), Board: "Arduino Uno"

Sketch uses 1,068 bytes (3%) of program storage space. Maximum is 32,256 bytes.
Global variables use 11 bytes (0%) of dynamic memory, leaving 2,037 bytes for local variables. Maximum is 2,048 bytes.]]
avrdude: ser_open(): can't open device "/dev/tty.usbmodem1421": No such file or directory
ioctl("TIOCMGET"): Inappropriate ioctl for device
Problem uploading to board.  See for suggestions.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

The interface has changed, what was /dev/tty.usbmodem1421 is now (because I'm using a hub) /dev/tty.usbmodem141141. I change this by going into Tools -> Port in the IDE menu, and selecting the appropriate interface. The upload works, and I'm back with a blinking Arduino. Success!

From typing this brief example, I can see that:

  • pinMode() lets me declare which pins are inputs and outputs
  • digitalWrite() allows me to send a digital value to a pin.
  • the values OUTPUT, LOW and HIGH are constants whose values escape me just now
  • the delay() function seems to work in milliseconds.

This is reinforced by the manual's discussion of the code, which also tells me that

  • setup() and loop() are essential
  • Arduino C talks to the board's Hardware Abstraction Layer

and provides a sparsely-described equivalent program in C.

Looking at the structure of the files the IDE writes, choosing a filename of LED_blinks generates a project folder whose contents are the sketch file LED_blinks.ino:

$ tree chapter-8/
└── LED_blinks
    └── LED_blinks.ino
Written on October 29, 2015