Sending a program to your Arduino

First things first, let’s upload our first program to our Arduino and make sure it works!

  1. Plug your Arduino in
  2. Open up the IDE
  3. Prepare your sketch
  4. Select your Arduino
  5. Select your Serial Port
  6. Upload your sketch
  7. Stop it

1. Plug your Arduino in

Connect your USB cable to your computer and to your Arduino. Sometimes people fret about this part, but you don’t have to worry about breaking it unless you’re incredibly strong and reckless.

A light on your Arduino might come on at that point (mine is far too bright).

2. Open up the IDE

Now open up the IDE (it’s called Arduino on my Macbook). You’ll use the IDE to send your first program to the Arduino.

Don’t have the Arduino software on your computer? Head back to our supplies page.

3. Prepare your sketch

Every Arduino program is called a sketch. We’re going to be using an example program called Blink.

There are two menus in Arduino, which can kind of be confusing. There’s the one that shows up on the top of your screen, and the one with the little icons. When we want you to click an icon, we’ll explain what it looks like. When we just use words, you’ll want to use the standard text menus at the very top of the screen.

You can find it by selecting File > Examples > 01.Basics > Blink in the IDE, or by pasting the below into a new sketch.

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

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

4. Select your Arduino

You’ll need to tell the IDE what kind of Arduino it’s going to be talking to. Since yours is an Uno, you’ll want to pick Tools > Board > Arduino Uno.

5. Select your Serial Port

Now we’ll tell the IDE how the Arduino is connected. From the top menu in your program, select Tools > Serial Port and then select a port:

  • On Windows it’ll probably be COM3 or COM4 (or something else above COM2). You don’t need to be 100% sure which one - we’ll be able to pick again if it doesn’t work!

  • On a Mac it should be something like /dev/tty.usbmodem (there might be a few numbers after usbmodem).

Missing tty.usbmodem or a COM port? Not using an Uno? You migh want to check the official documentation for Mac OS X or Windows.

6. Upload your sketch

Now we need to upload the sketch to the Arduino itself.

In the green area there’s a little button with a right-facing arrow on it. When you hover over it, you should see the word Upload appear. Click it!

Your board will blink ferociously for a moment, then (hopefully) a little light to the left will start blinking, one second on, one second off.

CONGRATULATIONS, YOU ARE A WORLD-CLASS CHAMPION AND YOUR ARDUINO WORKS.

If something goes wrong, try selecting a different Serial Port for your Arduino. If it still doesn’t work, it might be that your Arduino is broken! That just happens sometimes, especially with the cheaper ones.

7. Stop it

Want your Arduino to stop blinking? Just unplug the USB cable. No need to warn it or turn it off or click an ‘Eject’ button or anything.

Moving on

Now that we know how to plug in an Arduino and get it running, we’ll learn about breadboards and then tackle a real project!

Want to hear when I release new things?
My infrequent and sporadic newsletter can help with that.