Friday, 2 March 2012

A little venture with electronics

The chaps from Farnell Element14 have kindly sent me an Arduino Uno to have a look at and experiment with.

When the package first arrived, I assumed it was something else as it was no bigger than a pack of cards. However I unwrapped it and yes it was indeed an Arduino Microcontroller.



When you get it open there is a small leaflet explaining what you have bought and the Arduino Uno itself. The packaging points out that the Arduino is made and tested in Italy. And quite rightly too, Arduino is a great Italian success story and counters the current bad press that countries like Italy get in the financial press. The Arduino Uno is just the latest in a range of boards from some rather smart chaps who wanted a board that was cheap and open source for teaching students about microcontrollers and programming. You'll also find a sheet of stickers in the box, which you can put on your project once you've finished it.



What I like about these boards is that they are pretty much ready to go out of the box. The one thing you do need to provide (other than a computer to programme the board) is an A-B USB cable.



You also need to download the software from the Arduino site. And if you are on Windows you will also need to install a driver.

My previous ventures with working with computer control included a GCSE project to build an X-Y plotter controlled from a ZX Spectrum. I initially did not understand that the ports on the back of the Spectrum were directly connected to the main bus. I wired up a switch and when I pressed the memory chips were fried. Once those were replaced, I purchased a proper I/O adapter and got my stepper motors and solenoids wired up just fine. My later ventures were not much more successful, I wanted to build some Knight Rider style lights for a custom PC case so got hold of a PIC and built a PIC programmer. The code worked fine in the simulator but I could just not get it to run on the hardware so that project was abandoned and I just wired the LEDs together instead and had a big flashing bar.

Given these previous projects, I thought it wise to read "10 ways to destroy an Arduino" before getting started. I also watched some of Jeremy Blum's tutorial videos on the Element14 Arduino group. I discovered to my joy that the designers had cleverly wired up an LED to pin 13 on the board so I did not even need to have any additional circuitry to get going.

LED wired to pin 13 - Orange light on the left hand side

The are a range of examples provided with the install so I fired up the blink code and had a play with getting it uploaded and tweeking the values to flash the LED in different rhythms.
  • /*
  • Blink
  • Turns on an LED on for one second,
  • then off for one second, repeatedly.
  • This example code is in the public domain.
  • */
  •  
  • void setup() {
  •   // initialize the digital pin as an output.
  •   // Pin 13 has an LED connected on most Arduino boards:
  •   pinMode(13, OUTPUT);
  • }
  •  
  • void loop() {
  •   digitalWrite(13, HIGH); // set the LED on
  •   delay(1000); // wait for a second
  •   digitalWrite(13, LOW); // set the LED off
  •   delay(1000); // wait for a second
  • }
Source Code for Blink

Having a microcontroller and not controlling anything would be a bit boring but it's nice to familiarise yourself with the setup without having to get out a soldering iron. The other good thing about the Arduino from a makers perspective is that you can buy or assemble add-on boards or "shields" with features such as display, PWM motor control, data logging, sound, radio or networking. So you don't need to be an electronics wiz to put together sophisticated solutions. Because Arduino is open source there are also people who are adapting the basic board such as the Nanode project. The Makerbot also makes use of Arduino and their latest motherboard is in the form of an Arduino shield.

I do have some plans for this board that will require some electronics and a little programming, the idea is hack apart an old computer mouse and mount the sensors so I can read the angle on a simple rotary table. The angle would be displayed on an LCD display. Conveniently, there are plenty examples of code and circuits out on the internet so it should just be a case of putting a few key electronic parts together and some simple coding using existing libraries.

A big thanks to Farnell Element14 for making this project possible.

3 comments:

Anonymous said...

Why don't you try a Raspberry Pi?

Andy from Workshopshed said...

I've looked at the Raspberry Pi and I think it's complementary rather than a rival to the Arduino. From an embedded perspective I can see the Pi doing things like providing a Web UI to a monitoring system or being used to create a rival to the Mach in a box. I'm gussing you could also use a Raspberry Pi for a centring microscope project or a GUI like the one on this industrial plasma cutter. I can also see them working together with the Raspberry Pi either being the programming station or interfacing to the outside world with the Arduino connecting up to the hardware. People already produced a general IO card for the Pi but there is no reason you could not use the Arduino for that task instead.

Andy from Workshopshed said...

Just discovered "Internet of Things" over on meetup.

Workshop Practice Series