The Arduino Inventor's Guide

Read The Arduino Inventor's Guide for Free Online

Book: Read The Arduino Inventor's Guide for Free Online
Authors: Unknown
adjusting the editor font size so it’s comfortable for you to read. We also like to check Display line numbers and uncheck Save when verifying or uploading . Line numbers will help you navigate around your code easier, and unchecking the auto-saving feature will allow you to quickly test code without having to save it each time. Arduino is completely open, so if you want to, you can also click the
preferences.txt
file and adjust many other features.
    FIGURE 1-13: Arduino Preferences window

TEST DRIVE: PLUGGING IN THE ARDUINO FOR THE FIRST TIME
    When you have the Arduino IDE and drivers fully installed, connect your Arduino board to the USB port of your computer using the appropriate cable. The power LED should turn on, and if your board is completely new, you should see an LED, labeled 13, blinking as in Figure 1-14 . Your computer is powering the Arduino board through the USB cable, and it’s running code that was installed at the factory. Unlike a computer, an Arduino can only store and run a single sketch at a time. The standard test sketch loaded onto an Arduino is a simple LED blink. With your board plugged in, you’ll set up the IDE so that you can write your own sketch.
    NOTE
    If you plugged in your board before installing the IDE and drivers, you may need to restart your computer.
    FIGURE 1-14: The LED labeled 13 blinks when you power a new board.

Choosing Your Board in the IDE
    Depending on your computer or operating system, it may take a little bit for the computer to identify the new hardware you just plugged in and associate it with the drivers you installed. After your computer recognizes the new device, click Tools and mouse over the Board option, as in Figure 1-15 .
    FIGURE 1-15: The Board selection list in the Tools menu

    A list of pre-supported Arduino boards should appear. If you’re using a standard Arduino Uno or the SparkFun RedBoard, select the option Arduino/Genuino Uno . If you end up using a board other than an Uno or RedBoard in the future, select the correct Arduino based on your board’s documentation—this book assumes that you’re using the Uno or an Uno derivative.
Selecting the Communication Port
    Each device that’s plugged into your computer has a unique communication port identifier. You need to configure the IDE so that it knows which port your Arduino is connected to. To do this, first select Tools ▸ Port to see the communication port options for your device. You’ll see different options depending on your operating system.
On Windows
    If you’re using a Windows PC, you may see COM3, COM4, or another numbered COM port, as shown in Figure 1-16 . Select this option. If no options show up, see “ Basic Arduino Troubleshooting ” on page 27 .
    FIGURE 1-16: Selecting the communication port on Windows

On OS X and Linux
    On Mac or Linux machines, the communication port should be listed as
/dev/cu.usbserial-A
, where the

is a string of random characters unique to your Arduino. Select this option. You may see more than one port listed, as in Figure 1-17 , but only the one with this unique ID string will map to your Arduino. If no options show up, see “ Basic Arduino Troubleshooting ” on page 27 .
    FIGURE 1-17: Selecting the communication port on OS X

AN ARDUINO “HELLO, WORLD!”
    “Hello, world!” is the classic first program that many beginning programmers write. In most other programming languages, this program displays Hello, world! to the screen. Because the Arduino doesn’t have a screen, its version of “Hello, world!” is a blinking LED.
    For your first sketch, we’ll show you how to use an example that comes with the Arduino IDE. With your board connected to your computer, click the File drop-down menu and select Examples ▸ 01.Basics ▸ Blink as shown in Figure 1-18 to open a sketch called
Blink
.
    A new IDE window containing the Blink sketch should open. In this window, click Sketch ▸ Upload or click the Upload icon. The IDE will turn this

Similar Books

Football Double Threat

Matt Christopher

Veiled Desire

Alisha Rai

Lachlei

M. H. Bonham

Tradition of Deceit

Kathleen Ernst

Icebreaker

Deirdre Martin

Julius Caesar

Ernle Bradford