Chances are, if you found this site then you already know what a microcontroller is. But you might also be here to educate yourself, in which case you should read this post to get a very brief introduction. Fair warning : this post contains a lot of TLA, Three-Letter Acronyms. This section contains compendiums covering every aspect of using microcontrollers, both hardware and software. I’m mostly interested in STM32 microcontrollers, but not exclusively. And if you’re expecting Arduino, expect again. As with everything on this site (and as Ryan Reynolds would say), I’m only dealing with the pro shit.
A microcontroller, usually shortened MCU for Micro Controller Unit, is a specific type of microprocessor, like the CPU (Central Processing Unit) in your computer. In fact, it is more accurate to compare it to the SoC (System On Chip) at the heart of your smartphone or tablet. Whereas a CPU is just a processor and needs a lot of hardware around it, an MCU contains almost everything it needs to be a complete computer and tackle almost any task : ROM, RAM, Flash, USB… the larger ones have integrated Ethernet, SD Card interfaces and even a basic GPU. They are equipped to do everything from blinking an LED to calculus and artificial intelligence. It’s basically just like the Colonial Marines :
Except I don’t think the Colonial Marines can do calculus.
Pretty much anything you can connect to a processor can be found in one MCU or another. This makes them very useful in many, many applications. That means there are more MCU’s in your home right now than there are computers, and you don’t even see them. They are the ninjas of computers.
They are single-digit cheap, use very little power, don’t require cooling, and you’ll find them in anything “smart” or “connected”, like a lightbulb, but also in washing machines, coffee makers, drones, the list is endless. They are also the brains of every Arduino, which you might have heard of. The “internet of things” exists solely because of microcontrollers and marketing. But mainly microcontrollers.
This is what they look like in the wild :
(Left to right : An STM32 Nucleo module, an MBED LPC1768 module on its expansion board, and of course an Arduino Nano)
Of course, they aren’t perfect : otherwise your PC would have a microcontroller inside instead of an expensive processor with a huge heatsink. To keep it short, microcontrollers are designed to be cheap and low-power, which means they are missing important features found in a processor. Chief among them, an MMU (Memory Management Unit) which is something you absolutely need if you’re going to run a modern operating system like Linux or Windows.
To summarize, you need an MCU for any project that requires a really cheap and tiny computer that could run for days on battery. If you don’t need tiny and money is not an issue, just use a computer.