A microcontroller is a small, programmable computer on a single integrated circuit. They are called embedded microcontrollers because they are usually embedded into a device in order to run a program to do a specific task. “A microcontroller takes input from the device it is controlling and controls the device by sending signals to different components in the device. ” (How Stuff Works).
Microcontrollers are found in thousands of everyday devices. For example, a microwave oven includes a controller that takes input from a keypad, displays output on an LCD display (such as the cooking time) and controls an electromechanical switch (a ‘relay’) that turns the microwave generator on or off.
There are many different types of microcontroller. Here are a few of them:
The BBC Micro:bit
The BBC Micro:bit is a microcontroller – a tiny programmable computer that was developed to help children learn the basics of programming in an easy, accessible way. It includes inbuilt sensors to register movement, light and temperature, and has a screen with a matrix of LEDs so that it can display letters, numbers and symbols. It even has a compass, and bluetooth connectivity. A small USB cable connects it to a computer, to make it easy to download programs onto the micro:bit.
Programming the micro:bit
Below is a screenshot of the initial code I created – it tells the microcontroller to do three things:
- Count upwards whenever button A (the left button) is pressed
- Count downwards when button B (the right button) is pressed
- Display a random number between 0 and 6 when the microbit is shaken (like a dice)
Here’s a brief demo of how the above code works: