Lab 1: Orientation to the Mac Lab and Arduino
What is Arduino?
- Welcome to the Mac Lab
1. Welcome to the Mac Lab
1.1 First Time Login
- Your username is your uregina.ca username - the same one you use to login to URCourses or any campus computer.
- Your password is the same as your URCourses password.
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:
- Access most computers labs on campus
- Printing on campus
- Access Online
- Store information
from this web page
Information Services - Student Support.
- Find Username and Password, or
- Change Password, or
- Enable Printing
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:
- Dock: used for launching programs and organizing frequently used items.
- Desktop: used for storing stuff. NOT generally used for shortcuts to applications.
- 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.
- Application Menu Bar: One application, called the front application, is active for user interaction at a time. This applications main menu is displayed here.
- 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.
- 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:
- Single click application icons in the Dock
- Find and double click most user programs in Finder menu | Go | Applications or a subfolder
- Find and double click useful utilities in Finder menu | Go | Utilities
- Use Spotlight if you are lazy like me or if you can't find a program or file where you expect it to be. Spotlight is awesome! The concept should be familiar to Windows 7 users who have a similar feature in their Start menu.
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:
- Switch to the program, click its name in the menu and select Quit
- Switch to the program and press Command-Q
- Right-click on a program and select Quit.
If you would like more information about the Mac Environment, including customizations, see macenviron.html.
2. 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:
- The hardware - the Arduino Uno
- The software - the Arduino IDE (Interactive Development Environment)
The following two sections will discuss the hardware and the software.
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.
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).
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:
- 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.
- 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)
Throughout this lab you will connect wires to many of the pins encircled in pale red:
- 5V is for power. Try to use a red wire to connect to this pin. If you follow this convention, it will be easier to figure out where wires are going to or coming from.
- GND is for ground. Notice that there are two ground pins; it does not matter which one you use. Try to use a black wire to connect to this pin.
- A0 to A5 are "Analog In" pins. Compared to binary input, which is either HIGH (pulled to +5 volts) or LOW (pulled to ground), the values are between 0 (for 0 volts) and 1023 (for 5 volts).
- 0 to 13 are Digital I/O Pins. Each of these can be used as an input or an output. You will notice that pins: 3, 5, 6, 9, 10, and 11 have a tilde (~) beside them representing PWM (Pulse Width Modulation). This means that you can output in the range of 0 (~0V) to 255 (~5V) instead of just outputting HIGH or LOW.
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.
4.1 Opening Arduino on the Mac
- Type arduino into Spotlight
- Click the match that appears in the "Applications" section of the list
The Arduino IDE will now start running.
4.2 Overview of Environment
The following diagram demonstrates the areas of the Arduino IDE:
There are three main regions:
- Input Area - this is where you will type or edit code.
- 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.
- 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.
At this point, you should plug your Arduino devices into the USB Port for the Mac.
If you get the following message, click Cancel:
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:
- Under the Tools menu, select Serial Port and /dev/tty.usbmodem1d11 (there may be slight differences in the numbers after usbmodem on your machine)
Note: On Windows machines, the settings for the Serial Port will be different (likely some COM port, eg. COM3). Also note that on Windows machines, the Tools menu and Upload buttons may be slow if your OS knows of many COM ports.
- Under the Tools menu, select Board and Arduino Uno
4.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.
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.
Let us try running the code:
- Press the Verify button.
You will notice messages "Compiling..." and then "Done compiling"
in the Status bar (below the code).
- Press the Upload button.
notice a couple of things:
- messages of "Uploading to I/O Board.." and then "Done uploading" in the Status bar.
- TX and RX lights will blink when the uploading occurs.
- 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.
A little more about these lights:
- The TX and RX lights flash when data is being transmitted to or from the computer (using the USB connection).
- 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.
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:
- Get a key card for CL 135 from the CS Department Office (3rd floor of Colege West, same room as Math and Statistics office).
- Spend a few minutes putting your kit "together". For example, you can:
- Peel the protective paper, which sort of looks like cardboard, off the platform. Yes, the paper does come off, revealing a beautiful blue base.
- Put the Arduino on the platform with the included bolts, spacers and nuts. Tip: use Loctite 242 (blue) to keep the nuts securely fastened.
- Stick the breadboard to the platform beside the Arduino.
Steps 2 and 3 (above) are illustrated in the following diagram modified from page 02 of the "Experimenter's Kit for Arduino":
- Put the little rubber pads on the bottom of the platform to keep the bolts from scratching your favorite tables and desks.
- Organize your plastic tool case. Notice that you have some plastic pieces that match the box, you can cut these and make divisions in the box to suit your needs.
- Take the resistors off the sticky tape.
- (Optional) For each resistor, you can bend the leads down so they are 90o from the cylinder. Then snip them so they are ~10mm to 3/4" long. Be careful not to cut them shorter than 6mm or 1/4". Some people find it easier working with the resistors without all the extra wire. You can experiment by trimming half of the resistors and see which you prefer.
- Get twist ties to keep your wires organized
This is something that you can do at home (specific to the platform that you are on):
- Install the Arduino IDE from: http://arduino.cc/en/Main/Software
- Install the Driver
More instructions are included on page 03 of your "Experimenter's Kit for Arduino":