Microcontroller Shootout – Arduino Uno

Arduino Uno R3The next Microcontroller we’re going to look at is the Arduino Uno R3 – This is a open source and low cost development board that has an ATmega328 and 14 digital input/output pins (6 can be used as PWM outputs) it also has 6 analog inputs. There is also a USB connection for uploading sketches (programs) from your computer and a ICSP header so you can program it directly if you wish.

We’ll mention it again; this isn’t being directly compared to the other development boards we’re reviewing and hopefully you can make your own mind up regarding what to use after this shootout series. We’ll be doing a summary of all microcontrollers when we come to the end of the Shootout.

There are various types of Arduino available; we chose the Arduino Uno due to the fact that we believe it’s the easiest to get started with and is also the lowest cost of the Arduino family – If you’re just getting started with programming microcontrollers then this would be an entry level product for learning and prototyping.

We’ll be running the same example as we did with the Parallax Propeller, by setting up the board and development environment and flashing an LED with code. Pin 13 is by default an LED actually on the board it’s self, so we’ll be flashing an external LED hooked up to a small breadboard.

The specification summary can be seen below (from the Arduino.cc website) :

MicrocontrollerATmega328
Operating Voltage5V
Input Voltage (recommended)7-12V
Input Voltage (limits)6-20V
Digital I/O Pins14 (of which 6 provide PWM output)
Analog Input Pins6
DC Current per I/O Pin40 mA
DC Current for 3.3V Pin50 mA
Flash Memory32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM2 KB (ATmega328)
EEPROM1 KB (ATmega328)
Clock Speed16 MHz

A link to the Schematic for the Arduino Uno R3 can be viewed by clicking here: Arduino Uno Rev3 Schematic  or you can find out more information from the official page on Arduino.cc.

Let’s get started with it.

You can start with hooking the Arduino up to your computer with the USB cable, this will provide power as well as a connection to upload your programs. Do not connect both the power connection and the USB cable at the same time.

We can start by downloading the software from Arduino.cc – There is a “Download” button on the menu bar at the top, so it is very noticeable when on the website. You’ll be wanting to download the “Arduino IDE” for your operating system, note that the IDE is supported on Windows, Mac and Linux as well as the source code being available for download.

If you’re on Windows; I would select the “Windows Installer” option as this will also create the relevant short-cuts and place the Arduino software in Program Files.

If you’re on a Windows 7/8 or Mac then installing any drivers are usually not needed and the Arduino will automatically be detected when it’s plugged in. However, if for some reason the Arduino isn’t automatically detected then you can follow the steps below (found on the Arduino.cc website) to install the drivers manually.

Installing the Drivers

Installing drivers for the Arduino Uno or Arduino Mega 2560 with Windows7, Vista, or XP:

  • Plug in your board and wait for Windows to begin it’s driver installation process. After a few moments, the process will fail, despite its best efforts
  • Click on the Start Menu, and open up the Control Panel.
  • While in the Control Panel, navigate to System and Security. Next, click on System. Once the System window is up, open the Device Manager.
  • Look under Ports (COM & LPT). You should see an open port named “Arduino UNO (COMxx)”
  • Right click on the “Arduino UNO (COmxx)” port and choose the “Update Driver Software” option.
  • Next, choose the “Browse my computer for Driver software” option.
  • Finally, navigate to and select the driver file named “arduino.inf”, located in the “Drivers” folder of the Arduino Software download (not the “FTDI USB Drivers” sub-directory). If you are using an old version of the IDE (1.0.3 or older), choose the Uno’s driver file named “Arduino UNO.inf”
  • Windows will finish up the driver installation from there.

From here you should now have the Arduino Software installed and the Arduino detected on your machine and have something like the image below after launching the software.

Ard1After launching the Arduino IDE you’ll first notice it’s blank! No welcome or “first time use” instructions; which if you haven’t read up on previously this can be a little frightening.

Luckily, there is a whole bunch of example code already built into the IDE. Click the File > Examples menu and you’ll see just how much is available at the click of a button.

There are also plenty of tutorials under “Learning” on the Arduino.cc websiteIt would be nice to have a splash screen with help for first time users though, pointing them to the Learning section and Example code.

Now we’re ready to go with creating our first LED Blinking program; actually I don’t need to do any coding at all as this is an example that built-in. From the File > Examples menu select the 01. Basics and Blink program.

The IDE should of opened up in a new window with the following code:

The actual code is really simple. The idea behind the Arduino is based on these two functions void setup() and void loop(). The setup function is called at the start of your program and is only ran once; this is ideal for initialising libraries or setting values. The loop function is constantly looping around (what an ideal name!) and anything inside this function is called over and over and over again.

You can see in the setup function that we tell the program that we want to be able to set a Pin as an Output and this is done using the pinMode function; the same thing is used when setting the pinMode as an Input.

Inside the loop function we write a HIGH value to the Pin number that led represents; which is defined at the top as 13. Setting HIGH and LOW is as good as saying 1 and 0 or On and Off. The next line then tells the program to delay by 1000 milliseconds (1 second) and then turn off the LED by writing LOW to Pin 13, we then delay by 1 second again and it repeats in an infinite loop and the result is a constant flashing LED.

IMG_20140130_134533We setup a basic breadboard, LED and Resistor to test this code and we changed the led and kept the Pin as 13 then connected a wire from the breadboard to Pin 13 on the Arduino;

The result, you can see on the left hand side is a flashing LED every 1 second (note that we can’t actually show it flashing in a photo!)

The example code we ran was actually done on Windows, Mac and Linux but this photo seemed the best out of the three that was taken. Click the image on the left to see a larger photo.

BlinkLEDYou can see on the schematic on the right how we connected the LED to Pin 13 on the Arduino Uno.

That’s all there is to getting an Arduino up and running; we’ve gone on a bit in this post as we have tried to cover as much information as possible. Once you get the hang of using an Arduino Uno all of this will come naturally and easier with experience.

If you do have any questions, comments, suggestions or if you think we’ve missed something then please feel free to message us by leaving a comment below or on our contact us page.

The diagram was created by using the Fritzing design software (you can read more about that here)

One other thing to mention is what we have found recently. You do not have to use the Arduino IDE – There is a project called Visual Micro which allows you to program your Arduino’s inside of Visual Studio.

From the Visual Micro Codeplex website: “The Arduino IDE for Visual Studio and Atmel Studio 6.1 provides a free, simple and fully compatible alternative to the Arduino IDE. Installation takes 10 minutes. This solution is suitable for both experts and novices. Arduino for Visual Studio and Atmel Studio Instructions, Documentation and Forum

That about covers it with this shoot-out; stay tuned for more microcontroller shoot-outs coming soon.

 

Email this to someoneShare on Google+Pin on PinterestTweet about this on TwitterShare on RedditShare on Facebook

Leave a Reply

Your email address will not be published. Required fields are marked *

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