Arduino Uno – Getting Started

I received my Arduino Uno from Farnell today. One of the nice things about the Arduino is that for a piece of hobbiest electronics, it’s rather attractively packaged!

To do anything useful with the Arduino you’ll need an “A to B type USB cable”. You’ve almost certainly got one already, they commonly come with printers and I always seem to find them around my flat hiding behind furniture.

Download the Arduino environment here. The resulting zip file should be extracted automatically, copy “Arduino” to “Applications”.

Plug in your Arduino. You should see the following dialog pop up:

Click “Network Preferences”, when the config dialog pops up just click apply.

Load the Arduino software!

In the Arduino software select File->Examples->1.Basics->Blink

Select the correct serial port. Tools->Serial Port->Something. Where something should be /dev/tty.usbmodemXXX if there’s more than one, some trial and error maybe involved.

Click the upload button (highlighted in yellow below):

You should then see one of the lights on the board start flashing away (again highlighted):

We can now start hacking away at the code. For example we can make the light blink out an SOS signal! The code is basically standard C. The Arduino IDE does some funky preprocessing which lets you get away without including a bunch of header files, but as I understand it it’s really just C underneath.

Here’s my SOS code:


/*
  SOS
 */

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
}

void loop() {
  // SOS
  short_pulse();
  short_pulse();
  short_pulse();
  long_pulse();
  long_pulse();
  long_pulse();
  short_pulse();
  short_pulse();
  short_pulse();
  delay(5000);              // wait for a while
}

void short_pulse() {
  digitalWrite(13, HIGH);  // set the LED on
  delay(200);              // wait for a second
  digitalWrite(13, LOW);   // set the LED off
  delay(500);              // wait a while
}

int long_pulse() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(500);               // wait a while
}

Hit Upload again and you should see the light blinking an SOS at you! Embedded programming shouldn’t be this easy it isn’t right!! :)

If you’re in the UK you can get an Arduino Uno from Farnell here.

One thought on “Arduino Uno – Getting Started

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>