The Arduino Microcontroller

arduinounotop.jpg

The Arduino Uno is a microcontroller made and designed in Italy. Have a quick look at Adafruit's decription of this and related devices (there are many). A microcontroller is not the same as a //microprocessor//. The Raspberry Pi is a microprocessor. You can run an operating system on the Pi. The Arduino is far simpler; think of it as a programmable chip. You write the program on a computer, compile it (translate it into machine code), upload it onto the Arduino, and the Arduino will attempt to follow your instructions. Because of its simplicity it is not as powerful as something like a Raspberry Pi, but it is far more robust, easy to use, is better able to control and accept input from devices, and is cheaper!

You will not need to set up any software as this has already been done. But for an introduction of the system and software have a look at the Getting Started page on the Adafruit website.

Why use an Arduino Board? Watch the Arduino Movie on Vimeo. (But not while you are in the lab!!!) The Wikipedia page on the Arduino is also quite cool and contains a load of information.

Basics

What's on the board?

We will be using the Arduino Uno. This is the most commonly used board for hobby projects. For a full description of the board, chips, memory, I/O pins, voltages, etc., see the Arduino Uno page.

Getting Started & Troubleshooting

Need help setting up an Arduino board, or something has gone wrong? Have a look at the Getting Started with Arduino page for information.

Foundations

The best way to learn about an Arduino board is to use it. So first try the examples given below. At least the simple ones. Once you've got your hands wet, you may want to know more about it: What is a //sketch//? What are the pins on an Arduino board for? This sort of information can be found on the Foundations page. The most useful bits are:

Example Sketches

Here are some example projects that introduce you to various aspects of the Arduino. If you are doing an SCM laboratory experiment, you may need to do only a few of these. Make sure you know which ones are necessary!

You will find more examples at the Examples page on the arduino.cc site.

Debugging your sketchs

There is no simple recipe for debugging sketches. But a few conventions will help:

  if (abs(speedLeft) < abs(speedRight))
  {
    digitalWrite(pinRled, HIGH);
    digitalWrite(pinLled, LOW);
  } 
  else if (abs(speedLeft) > abs(speedRight))
  {
    digitalWrite(pinRled, LOW);
    digitalWrite(pinLled, HIGH);
  }
  else
  {
    digitalWrite(pinRled, LOW);
    digitalWrite(pinLled, LOW);
  }

Or this one, without indents?

  if (abs(speedLeft) < abs(speedRight)){
  digitalWrite(pinRled, HIGH);
  digitalWrite(pinLled, LOW);
  }else if (abs(speedLeft) > abs(speedRight)){
  digitalWrite(pinRled, LOW);
  digitalWrite(pinLled, HIGH);
  }else{
  digitalWrite(pinRled, LOW);
  digitalWrite(pinLled, LOW);
  }

Reference Material

The most comprehensive reference for the Arduino is the arduino.cc website. Everything you need is likely here. But here are some specific pages that you will probably need to reference more often:

Have a look at the language reference as this is the first place to go when you get stuck and need to either debug a program (they call them //sketches//) or add a new language feature to your sketch.