Arduino uno User Manual
Hide thumbs Also See for uno:

Advertisement

Arduino Microcontroller Guide
W. Durfee, University of Minnesota
ver. oct-2011
Available on-line at
www.me.umn.edu/courses/me2011/arduino/
1 Introduction

1.1 Overview

The Arduino microcontroller is an easy to use yet powerful single board computer that has
gained considerable traction in the hobby and professional market. The Arduino is open-source,
which means hardware is reasonably priced and development software is free. This guide is for
students in ME 2011, or students anywhere who are confronting the Arduino for the first time.
For advanced Arduino users, prowl the web; there are lots of resources.
The Arduino project was started in Italy to develop low cost hardware for interaction design. An
overview is on the Wikipedia entry for Arduino. The Arduino home page is
http://www.arduino.cc/.
The Arduino hardware comes in several flavors. In the United States, Sparkfun
(www.sparkfun.com) is a good source for Arduino hardware.
This guide covers the Arduino Uno board (Sparkfun DEV-09950, $29.95), a good choice for
students and educators. With the Arduino board, you can write programs and create interface
circuits to read switches and other sensors, and to control motors and lights with very little effort.
Many of the pictures and drawings in this guide were taken from the documentation on the
Arduino site, the place to turn if you need more information. The Arduino section on the ME
2011 web site, https://sites.google.com/a/umn.edu/me2011/, covers more on interfacing the
Arduino to the real world.
This is what the Arduino board looks like.
1

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the uno and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Arduino uno

  • Page 1 Many of the pictures and drawings in this guide were taken from the documentation on the Arduino site, the place to turn if you need more information. The Arduino section on the ME 2011 web site, https://sites.google.com/a/umn.edu/me2011/, covers more on interfacing the Arduino to the real world.
  • Page 2 The Arduino programming language is a simplified version of C/C++. If you know C, programming the Arduino will be familiar. If you do not know C, no need to worry as only a few commands are needed to perform useful functions.
  • Page 3 PC 1.5 Moving On Connect your Arduino to the computer with the USB cable. You do not need the battery for now. The green PWR LED will light. If there was already a program burned into the Arduino, it will run.
  • Page 4 Click the Upload button or Ctrl-U to compile the program and load on the Arduino board. Click the Serial Monitor button . If all has gone well, the monitor window will show your message and look something like this Congratulations; you have created and run your first Arduino program!
  • Page 5 Push the Arduino reset button a few times and see what happens. Hint: If you want to check code syntax without an Arduino board connected, click the Verify button or Ctrl-R. Hint: If you want to see how much memory your program takes up, Verify then look at the message at the bottom of the programming window.
  • Page 6 Hint: Trim wires and component leads so that wires and components lie close to the board. To keep the Arduino board and breadboard together, you can secure both to a piece of fom-core, cardboard or wood using double-stick foam tape or other means.
  • Page 7 Did the LED light up for one second? Push the Arduino reset button to run the program again. Now try this program, which will flash the LED at 1.0 Hz. Everything after the // on a line is a comment, as is the text between „/*‟...
  • Page 8 The pinMode command sets the LED pin to be an output. The first digitalWrite command says to set pin 2 of the Arduino to HIGH, or +5 volts. This sends current from the pin, through the resistor, through the LED (which lights it) and to ground. The delay(500) command waits for 500 msec.
  • Page 9 +5 V +5 V PIN 3 PIN 3 Create and run this Arduino program void setup() Serial.begin(9600); void loop() Serial.println(digitalRead(3)); delay(250); Open the Serial Monitor window. When the switch is open, you should see a train of 1's on the screen.
  • Page 10 Watch the activity in the Serial Monitor window as you press and release the switch. 4 Controlling a Small DC Motor The Arduino can control a small DC motor through a transistor switch. You will need a TIP120 transistor, a 1K resistor a 9V battery with battery snap and a motor.
  • Page 11 Pin 2 Pin 2 can be any digital I/O pin on your Arduino. Connect the minus of the battery to the emitter of the transistor (E pin) and also connect the emitter of the transistor to Gnd on the Arduino board.
  • Page 12 5 Arduino Hardware The power of the Arduino is not its ability to crunch code, but rather its ability to interact with the outside world through its input-output (I/O) pins. The Arduino has 14 digital I/O pins labeled 0 to 13 that can be used to turn motors and lights on and off and read the state of switches.
  • Page 13 5 V signal. Second, the designer must write a program using the set of Arduino commands that set and read the I/O pins. Examples of both can be found in the Arduino resources section of the ME2011 web site.
  • Page 14 C, C++, Java, Ada, Lisp, Fortran, Basic, Pascal, Perl, and a thousand others. The Arduino uses a simplified variation of the C programming language. For any programming language, the instructions must be entered in a specific syntax in order for the computer to interpret them properly.
  • Page 15 if (j > 4) goto label instructions The commands inside the loop will be repeated six times. Following this, if the value of the variable j is greater than 4, the program will skip to the instruction tagged with the specified label, and if not, the line following the if statement will be executed.
  • Page 16 Although your program may pass cleanly through the syntax checker, it still might not do what you wanted it to. Here is where you have to hone your skills at code debugging. The Arduino did what you told it to do rather than what you wanted it to do. The best way to catch these errors is to read the code line by line and be the computer.
  • Page 17 0x64 B01100100 Labels are used to reference locations in your program. They can be any combination of letters, numbers and underscore (_), but the first character must be a letter. When used to mark a location, follow the label with a colon. When referring to an address label in an instruction line, don't use the colon.
  • Page 18 7.3 Program Structure All Arduino programs have two functions, setup() and loop(). The instructions you place in the startup() function are executed once when the program begins and are used to initialize. Use it to set directions of pins or to initialize variables.
  • Page 19 OR 8 The Simple Commands This section covers the small set of commands you need to make the Arduino do something useful. These commands appear in order of priority. You can make a great machine using only digital read, digital write and delay commands. Learning all the commands here will take you to the next level.
  • Page 20 For example, you can see the result of a math operation to determine if you are getting the right number. Or, you can see the state of a digital input pin to see if the Arduino is a sensor or switch properly.
  • Page 21 delay(100); You may have noticed when trying this out that if you leave one of the pins disconnected, its state follows the other. This is because a pin left floating has an undefined value and will wander from high to low. So, use two jumper wires when trying out this example. Here's one that checks the value of a variable after an addition.
  • Page 22 Serial.begin(9600); void loop() if (digitalRead(3) == LOW) { Serial.println("Somebody closed the switch!"); The if line reads the state of pin 3. If it is high, which it will be for this circuit when the switch is open, the code jumps over the Serial.println command and will repeat the loop. When you close the switch, 0V is applied to pin 3 and its state is now LOW.
  • Page 23 The for statement is used to create program loops. Loops are useful when you want a chunk of code to be repeated a specified number of times. A variable is used to count the number of times the code is repeated. Here is an example that flashes an LED attached to pin 2 five times int i;...
  • Page 24 void loop() {} while The while statement is another branch command that does continuous looping. If the condition following the while is true, the commands within the braces are executed continuously. Here is an example that continuously reads a switch on pin 3, and then when the switch is pressed, the condition is no longer true so the code escapes the while command and prints.
  • Page 25 This concludes the section on basic program commands. You can write some awesome programs using just what was described here. There is much more that the Arduino can do and you are urged to read through the complete Arduino Language Reference page on-line...
  • Page 26  Forgetting the semi-colon at the end of a statement  Misspelling a command  Omitting opening or closing braces Please send comments, suggestions and typo alerts about this guide to wkdurfee@umn.edu 11 Appendix On the following page is a summary of basic Arduino commands, with examples.
  • Page 27 (expr) {} While expr is true, repeat instructions in {} indefinitely For more commands see the ME2011 “Arduino Microcontroller Guide” and the Language Reference section of the arduino web site. Instructions in the setup() function are executed once. Those in the loop() function are executed indefinitely.

Table of Contents

Save PDF