

The other day I walked into the front room of our house to discover my frustrated wife hitting the alarm control panel with the door draft-stopping snake.
'Why are you doing that?'
She answered, exasperated, 'Because it keeps beeping every few minutes.'
'So how is hitting it going to fix it?' I questioned.
'I don't know, I have to try something, it's incredibly annoying...'
So, to aid my lovely wife, I sat there with her waiting for this elusive beep.
Magic
While we were waiting, I asked her:
'Have you ever wondered how things like alarms, electronic toasters, microwaves and air conditioners work?'
She replied with a blank look, 'No... I guess there's just magical electronicky stuff making it all happen.'
'Do you want to know?' I asked.
'No, just as long as it all works.'
'So, if you do not know how the alarm works, how do you think hitting it with a foam door snake will fix it?'
At that moment, the smoke detector above the alarm panel on the roof beeped its 'low battery' beep.
'Right, I will replace the battery then...' I said, holding back a grin.
The means behind the magic
In this series of articles, I am going to share with you the core of what drives a large percentage of electronic devices, from smoke detectors to cars, and give a basic demonstration by sharing a simple project demonstrating the core—the microcontroller.
A microcontroller is essentially a miniature and simplified computer on a chip, although not the type of computer that I am using to type this article. A computer can appear in many forms: a desktop computer, an iPad, an old mainframe, or a microcontroller.
Computers
To be classified as a computer, it must have certain components to it. At its core, it needs a CPU or central processing unit which is an incredibly complex circuit that can run a program. It also needs an area to load a program from, a hard disk or floppy disk in the case of your desktop computer, an area to load the program into to use as a temporary work space known as RAM, an input device which could be a keyboard and an output device to display results such as a monitor.
A desktop computer, such as the one you may be using to read this, is known as a general purpose computer: it can run thousands of different programs of great variety from games to spreadsheets, some of which require heavy duty work on the CPU.
The CPU on the computer I am using to type this article is capable of just over 1 billion mathematical instructions per second, to give you an idea of the amount of work required to give you fancy 3D game effects on your screen!
It is also worth mentioning that the difference between a calculator and a computer is that a computer runs a program or consecutive series of calculations and a calculator performs a single calculation.
The Microcontroller
Microcontrollers, on the other hand, only run the single program in a continuous loop that is downloaded and stored into its Flash memory. It is a computer on a chip, albeit a very simplified version, that is programmed to perform a specific function.
Microcontrollers have a CPU and generally three types of memory that is comparable to a general purpose computer: the Flash memory, where the main program is downloaded into and run from; the RAM, where program variables and constants are stored; and the EEPROM, which can be used to remember variables when power is removed.
There are literally hundreds of different microcontrollers made for a variety of various applications so for the purpose of this article, I will be referring to the very common microcontroller, the AT Mega 328P.
Operation
The software program loaded into its flash memory interacts with the chip's electronic signals, generally in the 0-5 volt range, on digital and analogue pins which can be configured by the program in the microcontroller to interact with input or output signals.
For example, a component called an LDR or Light Dependent Resistor, changes its resistance value depending on the amount of light falling on its surface and can be used to detect day and night—it is classified as an input sensor.
A component such as an LED or Light Emitting Diode, glows when a small current is sent to it, this is known as an output component and can be used in a few ways to signal an output by a simple on, off relating to yes or no or it can be used to flash a code.
If you wanted to create a device that would say, flash an LED when it was night time, this is very simple to do using a microcontroller and a few cheap components. It can also be done what I call the old way, using individual components to construct a circuit, but the real benefit is when you want to alter the behaviour of the circuit.
Say if you wanted the LED to stay on or flash at a certain speed—in the case of the microcontroller—you just need to alter the program and not spend hours adding, removing and changing components to get the desired effect.
In part two of this series I will create and explain the operation of a simple microcontroller circuit. Once you understand even their basic operation, you will start to notice them everywhere!
Turning sand and aluminium into tiny devices with millions of electronic components—that help us in so many ways—is an extraordinary feat of science and engineering.
Michael Dahlenburg is an Electronics Engineer currently working in the ATM industry. He is non-denominational and has previously been involved in church plants and assisting those in ministry. His interests include: enjoying family, home DIY, gardening, most things tech-related and driving his wife crazy with a constant stream of inventions! He lives with his wife Michelle and three children in God's own land of Southern Adelaide, Australia.
Michael Dahlenburg's previous articles may be viewed at http://www.pressserviceinternational.org/michael-dahlenburg.html