Monday, February 24, 2014

Arduino: The Universal Circuit

A bit of a departure from my usual topics but one which may well be of interest to like-minded folk. For a while I had heard about some kind of electronic doodad called an Arduino circuit. I never really understood what they did or how they could be relevant to me. Thanks to a Christmas purchase I now see the light and I am dusting off my coding fingers.

Old School Electronics Kits

As a kid, I had an old electronics kit. The connectors were springs which you bent to the side and shoved your wire between the rings. It came with a book of electronics projects. I even found a picture of it online.

My memory of this kit is spending hours running the connections in the book only to have it do very little when I threw the switch. Occasionally, a project would work but, even when it did, the wiring was so complex it was difficult to understand what was going on.

In Australia, we also had the “Dick Smith Electronics” kits. These were packets of electronic components you put together to create something e.g. the Knight Rider flashing LED kit or an FM transmitter. These were fun and educational but are no longer with us. Dick Smith Electronics went into retail and their kits are now a fond memory of Generation X electrical engineers.

Principle of Equivalence of Hardware and Software

To understand the evolution to Arduino, let us revisit some computing theory, specifically the Principle of Equivalence of Hardware and Software which basically states “anything you can do in hardware, you can do in software and vice versa”. As an example, we will consider a classic of the electronic set, the light bulb whose brightness varies based on the ambient light, as measured by a photo-resisistor (something whose resistance changes with the light it receives).

In our circuit we will have the photo-resistor, a light bulb and some clever arrangement of relays and/or transisitors and maybe some diodes to take the input of the photo-resisitor and transform this into a moderated current for the light bulb (we could probably make the circuit with a simple voltage divider in this case, but let us pretend).

The idea behind the Principleof Equivalence is we could also get our input (photo-resisitor) and output (light bulb) and link then via a processor running some software and generate the same result.

The Makey Makey

Now let us come to my Christmas present, which made everything clear; a Makey Makey. This is a cute device that plugs into your computer and lets you turn anything slightly conductive into a arrow key, mouse click or space bar.

I played with it for a bit, got the kids excited and on reading the web site, it informed me that when I wanted to take things further, the Makey Makey could be turned into an Arduino. From there it all fell into place.

In this case, the Makey Makey takes the input of closing a circuit by touching, say, a piece of fruit and converts this into the output of a keyboard key-press, via what is called a micro-controller (a small computer running code).

The Arduino

The Arduino is what the Makey Makey is based on. It has input and output ports, the micro-controller and a USB port so you can hook it up to your computer to power it and also to download your code into the micro-controller.

Luckily for me, the Arduino is programmed using C/C++ which is what I used to write back in my university days when coding physics simulation programs on Linux boxes. Here is the classic “hello world” sketch (what programs are called for Arduinos) for the Arduino which makes the on-board LED blink.

 

#define LED_PIN 13

void setup () {
pinMode (LED_PIN, OUTPUT); // Enable pin 13 for digital output
}

void loop () {
digitalWrite (LED_PIN, HIGH); // Turn on the LED
delay (1000); // Wait one second (1000 milliseconds)
digitalWrite (LED_PIN, LOW); // Turn off the LED
delay (1000); // Wait one second
}

 

This very readable code. In this case we only use one ‘pin’, number 13, as an output with no input. You write these programs in a free program you download onto your computer which also handles the uploading into the micro-controller via a button press.

My Project List and Tutorials

I already have my list of projects lined up:

  • A USB control panel for a Mame arcade emulator, using my Surface for the screen
  • Laser harp
  • Theremin using proximity sensors
  • Convertor for a traditional typewriter to make it usable as a full keyboard

but before I do these I am going through a series of tutorials on Arduinos on YouTube by Jeremy Blum. These are proving very useful for learning the practicalities of circuit design e.g. switch-bouncing and pull-up/down resisitors compared to my very theoretical knowledge of electrical circuits. It is also giving me a good idea of the parts I need for my kit.

How to Buy an Arduino and its Parts

I have bought my Arduino and the various parts to go with it (LEDs, a breadboard etc.) almost exclusively on eBay. A breadboard means there is no soldering which is also a big improvement on my old electronics days as a kid. The Arduino board can be bought for $10-20 and the other bits and pieces cost pennies. This is one hobby which can be explored without breaking the bank.

There are also pre-made add-ons for the Arduino called ‘Shields’ which plug onto the top of the Arduino board providing additional functionality e.g. GPS shields, ethernet shields etc.

Conclusions

Obviously not a CRM post but all work and no play makes for a grumpy IT worker so, if you are looking for a hobby which plays to your technical strengths and you always wanted to automate your home like Bill Gates then here is the chance. An Arduino and parts will cost about the price of a bargain box computer game and provide unlimited creative opportunity.

Have fun!

2 comments:

Jonas Rapp said...

One of these days...
I too will dive down those college microprocessor memory lanes and cheer like a child just for getting a diode to blink!
Thanks for the encouragement.

bantal silikon said...

this is good post...

i like this...

please can you visit here..

http://bantalsilikon01.blogspot.com/
http://bantalkekabumurah.blogspot.com/
http://bumbupecel1.blogspot.com/
http://bantalgood.blogspot.com/
http://bantalsilikonmalang1.blogspot.com/
http://bantalsilikonmurah.blogspot.com/

http://marinirseo.blogspot.com/
http://marinirseo.blogspot.com/
http://marinirseo.blogspot.com/


tengs very much...