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.
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.
Need help setting up an Arduino board, or something has gone wrong? Have a look at the Getting Started with Arduino page for information.
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:
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.
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); }
xxx
for the voltage_level
. Likewise, the function name sense_levels
is far better than my_function
.int pin_rightLED = 6;
tells us exactly what the function of pin 6 is: it controls the right LED. This also makes it easy to modify your circuit: say you move the right LED to pin 7, now all you need do is change one line in your sketch to read int pin_rightLED = 7;
. That's easier than modifying lines all over the code, isn't it? See how pins are labeled in the above code example.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.