Lab 1: Getting Started with Arduino and your ARDX Kit


Topics:

  1. Welcome to the Mac Lab
  2. What is Arduino?

  3. Hardware
  4. Software
  5. Homework

  6. References


1. Welcome to the Mac Lab

1.1 First Time Login

1.2 Novell Account Storage

Every student recieves a Novell computer account as long as you a student at the University.
You will need the Novell account to do the following:

You can do the following:
  1. Find Username and Password, or
  2. Change Password, or
  3. Enable Printing
from this web page Information Services - Student Support.

Check your U of R email regularly. Click this link to Check your email.

1.3 Local Storage

Any files you store on the local machine will only be available on that machine. If you plan to use them on another machine, copy them to a USB drive or your network account.

File permissions on stored files are too permissive - all files are world readable. See the section on Finder/File Management in macenviron.html to learn how to secure your data.

1.4 Desktop Overview

When you first login, your desktop will look like this:

desktop
  1. Dock: used for launching programs and organizing frequently used items.
  2. Desktop: used for storing stuff. NOT generally used for shortcuts to applications.
  3. Mac Menu: Log out, System restart and lock screen are here. You can also find information about your Mac. Has a permanent link to the Preferences panel, just in case you accidentally delete it from the dock.
  4. Application Menu Bar: One application, called the front application, is active for user interaction at a time. This applications main menu is displayed here.
  5. Utilities Area: You will find controls for Sophos Antivirus, a clock, display settings and volume here, just like the system tray or notification area on the Windows taskbar.
  6. Spotlight: The coolest tool in the utilities area. Helps you find what you need. Just click it and start typing the name of a file or application and watch the results pile in. Click on the best match.

1.5 Working with Programs

There are several ways to start programs:

1.5.1 Managing Running Programs

A light colored dot under a program's icon in the dock indicates that the program is running.

There's usually only one command menu in Mac OS X. It is at the top of the screen and it is controlled by the active program.

You can switch between active programs by clicking their icon in the dock, clicking a window that belongs to that program, or by using Command-Tab. This key sequence may seem similar to the Windows Alt-Tab that switches windows, but it is different. It switches Applications. If an application has no windows, or they are all minimized you will switch to it and the only indicator will be the menu bar. If an application has multiple windows and they are not all minimized, you will only switch to the last one you used.

On a Mac, windows have three buttons in the upper left corner. The red one closes the window, the yellow one minimizes the window, and the green one "zooms" the window. The meaning of "zoom" depends on the program. In iTunes it switches between player and music manager modes. In Safari it selects a window width and height that is large enough to optimally display the current page. In Firefox it maximizes the window as a Windows user would expect.

Mac applications have traditionally had multiple mini windows with no application container. If you have many applications running with many windows each, the desktop can get very cluttered looking. You can clean it up by hiding other programs.

1.5.2 Stopping Programs

If you want to stop a running program It is not enough to close its windows. The program will stay in memory waiting for you to use it again. Instead you must quit the program in one of three ways:

  1. Switch to the program, click its name in the menu and select Quit
  2. Switch to the program and press Command-Q
  3. Right-click on a program and select Quit.

If you would like more information about the Mac Environment, including customizations, see macenviron.html.


1. What is Arduino?

"Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments". (from http://arduino.cc/en/).

Arduino can use sensors ( for instance, temperature, tilt, and light) to test the environment and can control lights, motors, sound, and more. In later labs, you will get an opportunity to try out these things.

The goal of this lab will be to make a light on the Arduino blink. To get there, you need to know:

  1. The hardware - the Arduino Uno
  2. The software - the Arduino IDE (Interactive Development Environment)

The following two sections will discuss the hardware and the software.


2. Hardware

As mentioned earlier, Arduino consists of two major parts: the hardware (the Arduino board) and the software (the IDE). Let us consider hardware:

Not too long ago, working on hardware meant building circuits from scratch, using hundreds of different components with strange names like resistor, capacitor, inductor, transistor, and so on.

Every circuit was "wired" to do one specific application, and making changes required you to cut wires, solder connections, and more.

With the appearance of digital technologies and microprocessors, these functions, which were once implemented with wires, were replaced by software programs.

Software is easier to modify than hardware. With a few keypresses, you can radically change the logic of a device and try two or three versions in the same amount of time that it would take you to solder a couple of resistors.

(page 19 of Getting Started with Arduino by Massimo Banzi)

So, we don't have to solder things together. We will temporarily build our circuits on a breadboards and change code to modify how the device responds.

3.1 Breadboard

The key to building temporary circuits is a solderless breadboard. The following diagram (modified from page 94 of Getting Started with Arduino) depicts what the breadboard looks like inside (the colors here are not realistic, but meant to aid in describing the underlying pieces).

breadboard

The thing to note is that there are strips of metal (shown in blue or red) connecting the rows and columns together. Each hole has a spring loaded contact underneath so that when you poke a wire into the hole, a clip grabs onto it.

There are two kinds of metal strips:

  1. rails- (shown in red on the diagram above) connecting the 25 column holes. Notice that on your own breadboard, the rails are between the solid pair of red and blue lines. Typically the "+" column will be connected to the power and the "-" column will be connected to the ground.

  2. bars- (shown in blue on the diagram above) connecting 5 holes at a time in the direction of the letters. Notice that there is a gap in the middle.

3.2 The Arduino Board

Let us spend a few minutes looking at the board (modified version of the picture taken from http://arduino.cc/en/Main/ArduinoBoardUno)

Arduino Uno

Throughout this lab you will connect wires to many of the pins encircled in pale red:


3. Software

As mentioned earlier, Arduino consists of two major parts: the hardware (the Arduino board) and the software (the IDE). We will now learn about the Arduino IDE (A fancy way of saying the application where we will write our code). In a later lab we will examine the code.

3.1 Opening Arduino on the Mac

  1. Start typing arduino into Spotlight
  2. Click the Applicationmatch when it appears in the list (or hit enter, which is usually OK)
Spotlight

The Arduino IDE will now start running.

3.2 Overview of Environment

The following diagram demonstrates the areas of the Arduino IDE:

Areas

There are three main regions:

  1. Input Area - this is where you will type or edit code.

  2. Status Bar - this is where you get information about the status of your code. For instance, "Done compiling." or "Done uploading." are two messages that appear in the Status Bar.

  3. Program Notification Area - this is where you get additional details about the status of your code. Pay attention to this area if you notice that compiling or uploading are not working. Errors will be described here.

3.3 Settings

At this point, you should plug your Arduino devices into the USB Port for the Mac.

If you get the following message, click Cancel:

UnoDetect

You might have to adjust some settings of the IDE to get Arduino to work on the Mac. The following two diagrams illustrate the settings for the Arduino Uno in the Mac lab:

  1. Under the Tools menu, select Serial Port and the option with (Arduino/Genuino Uno) at the end. There may be slight differences in in what comes before this depending on your computer and which USB port you used.
    ToolsSerialPort

    Note: On Windows machines, the Ports are calle COM ports (eg. COM3). Also note that on Windows machines the Tools menu and Upload buttons may be slow if your computer lists too many disconnected COM ports.


  2. Under the Tools menu, select Board and Arduino/Genuino Uno
    ToolsBoardUno

3.4 Your First Blinky Light

And now, for the moment that you have been waiting for, let us see something happening.

Under the File menu, choose: Examples | Basics | Blink. As shown in the diagram below.

FileExamples

A new window will open with code in the input area. You now have your first sketch, which is a special name that Arduino uses to mean a program, or a unit of code that will be run on the Arduino board (hardware). We will be looking at that code more later.

BlinkCode

Let us try running the code:

  1. Press the Verify button. Verify
    You will notice messages "Compiling..." and then "Done compiling" in the Status bar (below the code).

  2. Press the Upload button.Upload
    You will notice a couple of things:
    1. messages of "Uploading to I/O Board.." and then "Done uploading" in the Status bar.
    2. TX and RX lights will blink when the uploading occurs.

  3. You should now notice a light (labeled "L") blinking on your board. Congratulations, you have gotten your first sketch running on the Arduino board!

The below diagram (modified from http://arduino.cc/en/Main/ArduinoBoardUno) illustrates where to look for the lights mentioned above.

arduino uno r3 lights

A little more about these lights:

  1. The TX and RX lights flash when data is being transmitted to or from the computer (using the USB connection).

  2. L is a special built-in light that is connected to pin 13. When the pin is a HIGH value, the light is on, when the pin is LOW, it's off. This might not mean anything right now, but you will notice that L blinks on and off after you have uploaded the code.

So, you have a light blinking. Next week, we'll learn more. This lab is just meant to introduce you to the Mac environment and Arduino.

3.5 Hello World

It is traditional for programmers to write a "Hello World" program when they start learning something new. Blink is a Hardware "Hello World". Sometimes a blinking light doesn't say much. It's nice to get messages you can read.

Arduino has two printing instruction, and a printing setup instruction. You can see them in use here:


void setup() {
  Serial.begin(9600);  // connect to the serial monitor at 9600 baud
}

void loop() {
  Serial.print("Hello"); // Send the text "Hello" to the serial monitor
                         // and stay on the same line.

  Serial.println(" World"); //Send the text " World" to the serial monitor
                            // and move to the next line
}

Type this sketch into Arduino IDE and upload it. Fix your errors until you get it right. Spelling is very important when you write sketches.

When your sketch is uploaded, press the serial monitor Serial Monitor button to see your message.


4. Homework

There is no official assignment - nothing will be marked. However, to prepare yourself for future labs and class assignments I recommend that you do the following: