12/27/2011

Our first Arduino Project - the modified Hello World

Sarah and I completed our first set of Ardunio projects today, and learned a bunch.  Mostly I learned exactly how the breadboard worked, with the power rails extending vertically the full length of the board, and the 5 pins of each terminal being electrically connected, with a channel separating the two halves down the center.  After I was done with the first project, it made all the sense in the world.

We did the first project from the book 'Arduino - A Quick Start Guide'.  Basically, you jump to the breadboard from pin 13 of the Arduino.  Pin 13 also powers the onboard LED, and thus has a 1K ohm resistor built in, so you don't need to add one to the circuit.  Here's the code:

const unsigned int LED_PIN = 13; const unsigned int PAUSE = 500;
void setup() { // <label id="code.welcome.setup"/>  pinMode(LED_PIN, OUTPUT); }
void loop() { // <label id="code.welcome.loop"/>  digitalWrite(LED_PIN, HIGH);  delay(PAUSE);  digitalWrite(LED_PIN, LOW);  delay(PAUSE); }
I was very glad to see how straightforward the code is, at least for now. I've taken a couple of C classes, but it's been awhile.  It is clear to see what is going on.  The first two lines are just setting constants - the LED is set to pin 13 and the time for the pause is set to 500 millisconds.  In the setup portion of the code, the pinMode command is used to set pin 13 to output mode.

In the loop, or main code of the program, the led is set to HIGH, or ON, then there is a 500 ms delay while the LED is on.  The next line turns the LED off, then another delay, at the end of which the loops starts all over again.

My daughter immediately began to play around with the settings in the original program, then got bored of that and wanted to add in some more LED's.  It is important to note that all 3 LED's in the video need resistors since pin 13 is not being used.  We used 1k ohm resistors across the channel for each LED.  The following video is not one of my better works, but it is pretty instructive as it shows her programming the app, making a few connections on the board, uploading the program, then troubleshooting a bug.

Camera work is terrible, but I think the information in the video could be useful.  Enjoy!  For the last mod of the Hello World program, I'm having her turn all 3 LED's on at the same time, then off at the same time.