Microcontroller Tutorial (1/5): What is a Microcontroller?

Atmega164 microcontroller (IC)This is my first of five posts in this microcontroller tutorial series. Throughout this tutorial, I will be building a microcontroller circuit while documenting the process. By following what I do, you can make your own at home.

My goal is to make a circuit that is as simple as possible, and which requires no external programmers or debuggers. You should be able to just plug it into a USB port on your computer and program it.

I have not planned this out in any way. I am just going to build it, and write about the process. Hopefully we’ll end up with a usable circuit.

In this first part of the microcontroller tutorial, I’ll start from scratch. I want to explain what a microcontroller is, in very simple terms. I want to get everyone on board before we dive into making the circuit.

What Is A Microcontroller?

You can think of a microcontroller like a tiny computer. You can connect things, like a small display, some buttons, a motor and some sensors. And you can put programs onto it and run them.

A microcontroller is an integrated circuit, and it can look like this:

Microcontroller tutorial: Atmega32 in a circuit

But it can also have many other shapes and forms.

What Can You Do With A Microcontroller?

Oh, where do I begin?

There are so many things you can do with a microcontroller.

You could build a robot. Or an MP3-player. Or a cellphone. Or a door-lock that unlocks your door automatically when you enter a code on your smart phone.

The possibilities are endless!

Let’s say you want to build a robot. You can connect an infrared sensor to use as vision for the robot. And you can connect a motor with some wheels to make it move.

Now, all you have to do is to make a program that reads from the infrared sensor and controls the motor. In your code, you can make sure the robot stops if it sees something in front of it, and make it turn to either left or right before continuing.

When you know how to build microcontroller circuits, there are almost no limits to what you can do! And by following this microcontroller tutorial, you will learn to use microcontrollers in your own projects =)

A Closer Look At A Microcontroller

Atmel-microcontroller-pinoutA microcontroller has several pins. Most of these pins are so-called input and output pins. And by using these pins, the microcontroller can interact with the outside world.

The microcontroller doesn’t do anything by itself. You need to tell it what to do, by making a program that you load into it to it. This is often called programming the microcontroller.

From the program you write, you can control the input and output pins.

So – by connecting something, such as a Light-Emitting Diode (LED) to an output pin, you will be able to switch the light on and off from your program.

An input pin could be used to check if a button connected to it has been pushed. Or to read the temperature from a temperature sensor.

In your program, you will be able to make decisions based on the input. So you can make a program that will start to blink a light if the temperature goes above or under a certain level. Put this into your beer-brewing room and you will get a visual alarm if the temperature for brewing is not right.

Programming a Microcontroller

Programming a microcontroller can seem a bit tricky because there are many confusing choices to make. I remember how I felt in the beginning. With all the available compilers, IDE’s, programmers and programming methods – no wonder you get confused!

So, let’s break it down.

These are the three steps necessary to program a microcontroller:

1. Write code
2. Compile your code to machine code
3. Upload the machine code to your microcontroller

What exactly to do at each step varies from microcontroller to microcontroller. But don’t worry – I’ll be guiding you through the exact steps needed when we get there.

Next Up In The Microcontroller Tutorial

It’s time to find a microcontroller and get to work. Finding a microcontroller isn’t necessarily as easy as you would like it to be. There are probably 58 billion different ones. Ok, maybe a little less. But a lot.

But I have some tips up my sleeve that will make it easier. But more on that in the next part of the microcontroller tutorial.

Throughout the tutorial, I will show you the steps you need to take to build your very own microcontroller circuit. You will then be able to use this circuit to build a blinking lamp, a robot, or some other idea of your own.

Continue to part 2 of the microcontroller tutorial >>

More Microcontrollers Tutorials