Arduino Projects For Dummies
Book image
Explore Book Buy On Amazon
Once you have the basics, you can now complete your first sketch. In front of you now should be an Arduino Uno R3, a USB cable, and a computer running your choice of operating system (Windows, Mac OS, or Linux).

Find the Blink Sketch

To make sure that the Arduino software is talking to the hardware, you upload a sketch. What is a sketch, you ask? Arduino was created as a device that allows people to quickly prototype and test ideas using little bits of code that demonstrate the idea — kind of like how you might sketch out an idea on paper.

For this reason, programs written for Arduino are referred to as sketches. Although a device for quick prototyping was its starting point, Arduino devices are being used for increasingly complex operations. So don't infer from the name sketch that an Arduino program is trivial in any way.

The specific sketch you want to use here is called Blink. It's about the most basic sketch you can write, a sort of “Hello, world!” for Arduino. Click in the Arduino window. From the menu bar, choose File→Examples→01.Basics→Blink.

image0.jpg

A new window opens in front of your blank sketch.

image1.jpg

Identify your board

Before you can upload the sketch, you need to check a few things. First you should confirm which board you have. You can choose from a variety of Arduino devices and several variations on the USB board. The latest generation of USB boards is the Uno R3.

If you bought your device new, you can be fairly certain that this is the type of board you have. To make doubly sure, check the back of the board. You should see details about the board's model.

image2.jpg

Also worth checking is the ATMEL chip on the Arduino. The ATMEL chip is the brains of the Arduino and is similar to the processor in your computer. Because the Uno and earlier boards allow you to replace the chip, there is always a chance, especially with a used board, that the chip has been replaced with a different one.

Although the ATMEL chip looks quite distinctive on an individual board, if you compare it to an older Arduino, telling them apart at first glance would be difficult. The important distinguishing feature is written on the surface of the chip. In this case, you are looking for ATmega328P-PU.

image3.jpg

Configure the software

After you confirm the type of board you are using, you have to provide that information to the software. From the Arduino main menu bar (at the top of the Arduino window on Windows and at the top of the screen on Mac OS X), choose Tools→Board. You should see a list of the different kinds of boards supported by the Arduino software. Select your board from the list.

image4.jpg

Next, you need to select the serial port. The serial port is the connection that enables your computer and the Arduino device to communicate. Serial describes the way that data is sent, one bit of data (0 or 1) at a time. The port the physical interface, in this case a USB socket.

To determine the serial port, choose Tools→Serial Port. A list displays of devices connected to your computer. This list contains any device that can talk in serial, but for the moment, you're only interested in finding the Arduino.

If you've just installed Arduino and plugged it in, it should be at the top of the list. For OS X users, this is shown as /dev/tty.usbmodemXXXXXX (where XXXXXX is a randomly signed number). On Windows, the same is true, but the serial ports are named COM1, COM2, COM3, and so on. The highest number is usually the most recent device.

image5.jpg

After you find your serial port, select it. It should appear in the bottom right of the Arduino GUI, along with the board you selected.

image6.jpg

Upload the sketch

Now that you have told the Arduino software what kind of board you are communicating with and which serial port connection it is using, you can upload the Blink sketch.

First click the Verify button. Verify checks the code to make sure it makes sense. This doesn't necessarily mean your code will do what you are anticipating, but it verifies that the syntax is written in a way Arduino can understand. You should see a progress bar and the text Compiling Sketch for a few seconds, followed by the text Done compiling after the process has finished.

image7.jpg

If the sketch compiled successfully, you can click the Upload button next to the verify button. A progress bar appears, and you see lots of activity on your board from the two LEDs marked RX and TX. These show that the Arduino is sending and receiving data. After a few seconds, the RX and TX LEDs stop blinking, and a Done Uploading message appears at the bottom of the window.

image8.jpg

You should see the LED marked L blinking away reassuringly: on for a second, off for a second. If that is the case, give yourself a pat on the back. You've just uploaded your first piece of Arduino code and entered the world of physical computing!

If you don't see the blinking L, review the preceding steps. Make sure you have installed Arduino properly and then give it one more go. If you still don't see the blinking L, check out the excellent troubleshooting page on the official Arduino site.

Without breaking a sweat you've just uploaded your first sketch to an Arduino.

About This Article

This article can be found in the category: