You are hereBlogs / blather's blog / My First Arduino
My First Arduino
While not my first microcontroller this is my first Arduino. I've been playing with PIC controllers loaded with the PICAXE bootloader for a while, probably out of some sick sense of nostalgia for the assembler class I took on the Motorola 68000 back in college. I quickly grew tired of managing bytes, words and double words and doing decimal maths the long way so I wandered over to see what the Arduino was all about.
The Arduino is noticeable because it has received a lot of attention lately and for good reason. The Arduino platform has exposed microcontrollers to the masses and has made it cheap. Both economically and in terms of learning time. For about $40 you can be writing code for your microcontroller and turning on and off LEDs -- for $60 you can be up and experimenting with most of the Arduino's base functionality with Sparkfun's Starter Kit for Arduino (a great kit and a great timesaver).
Once you have your Arduino the only other piece that is required is the Arduino IDE and the drivers to make your USB connection look like a serial port. The IDE is a java application so it is pretty painless, the FTDI USB Drivers are included in the IDE distribution and your windows machine should be able to find and install them automatically when you plug in the Arduino for the first time -- the OS X install is almost as painless.
To continue you'll need your Arduino, a USB cable, the IDE and drivers installed and an LED. Open up the Arduino IDE, follow along and we'll create the microcontroller equivalent of a 'Hello World' program.
The first thing to do is select your Arduino in Tools > Board of the IDE. For the Arduino pictured I have selected 'Arduino Duemilanove or Nano w/ ATmega328'. finally you'll need to select the correct port for the IDE to communicate with the Arduino in Tools > Port. Now we're ready to code some instructions. Enter the following in the IDE and I'll give a bit of a breakdown of what we just did:
Our first line #define LED 13 just allows us to assign a mnemonic to pin 13 so later we won't have to remember what pin we've connected the LED to, we'll just use the term 'LED'.
The void setup(){ } block is reserved for -- as one might assume -- setup. This block is run only once by the microcontroller at startup. In this instance we've set the mode on LED (pin 13) to output -- don't worry if this doesn't make any sense now (if you've just got to know start reading here).
With the void loop(){ } we get to the meat of the matter. The loop block will be looped through by the Arduino until power is removed or you upload another bit of code (or sketch as it is called in the Arduino world).
Now make sure your USB cable is connected at the appropriate ends and press the 'play' icon in the upper left corner. If there are no errors your Arduino should have loaded the sketch and will be running the loop continuously. But we won't see anything because we haven't attached an LED to the board yet.
Find yourself an LED and identify the anode and cathode sides. If the LED is just out of its packaging it should be easy to spot the anode by the extra long lead wire. If it is used or the leads are clipped you can spot the cathode side on round LEDs by a flat area or sometimes a notch in the plastic -- sometimes both.
After you've identified the anode (positive) side plug it into the slot identified as '13' in your Arduino. From there it should be an easy hop over to the 'GND' pin for the cathode (negative) side. Your LED should begin powering on and off in one second intervals and you have completed your first Arduino experiment.
To find more tutorials and information on what you might do with your Arduino check out the Tutorial Page. Have fun and don't burn your house down.
- beep to peeps
- blather's blog
- Login or register to post comments