What is a Microcontroller

While Raspberry Pi boards and Arduinos are extremely popular in the maker space, the two devices serve distinctly different purposes. While it's certainly true that there's overlap between the Pi and Arduino, they operate in fundamentally different ways. That's because one is a microcontroller and the other is a single-board computer (SBC). Learn all about what a microcontroller is, what it can do, and more!

What is a Microcontroller and How Does it Work?

What is a Microcontroller

A microcontroller is a tiny computer on an integrated chip. Onboard, a microcontroller unit (MCU) features one or more CPU cores as well as RAM and various programmable input/output (I/O) peripherals. Usually, MCUs feature program memory built-in in addition to some operating memory. Microcontrollers are engineered to fulfill embedded purposes rather than microprocessors found in computers and mobile devices.

Because of the intended use case in embedded devices, microcontrollers are engineered to run one specific program and complete a solitary task. Code executed sends various commands to power on and off the programmable I/O ports on a microcontroller and then control connected components accordingly.

What is a Microcontroller Made of?

A few main components comprise a microcontroller. First, there's the microprocessor, or CPU (central processing unit). Then, there are two types of memory: RAM or random access memory for storing data temporarily, and ROM or read-only memory for storing programs that in turn hold instructions to trigger various events. Code written for a microcontroller is compiled and uploaded to the board where it's stored in the MCU's ROM. An onboard program counter allows the microcontroller to execute commands based on the programmed code. Then, different inputs and outputs (I/O) allow for connected devices to be hooked up. I/O may consist of digital and analog I/O pins, servo motor controllers, and any number of connectors for adding peripherals. 

Parts that comprise a microcontroller:

  • Processor
  • RAM
  • ROM
  • Program counter
  • I/O

How is a Microcontroller Different from a Single-board Computer?

What is a Microcontroller - microcontroller vs single-board computer mcu vs sbc

Although both microcontrollers and single-board computers may be used interchangeably for select tasks, SBCs and MCUs are ultimately very different. Whereas a microcontroller focuses on running one program and executing one single task, a single-board computer can multi-task. Additionally, SBCs must run an operating system (OS) with programs executed on top of that OS. Contrastingly, a microcontroller merely executes code and doesn't feature an OS running on the board itself. Instead, code is written, compiled, then sent to the MCU where the processor handles program execution. 

For example, a microcontroller might blink an LED at a certain interval. Code tells the MCU which pins to power on and off and at what frequency. Those commands change the state of those pins to power on and off a connected LED. Of course, you can hook up multiple components and write various commands strung together for increasingly complex operation. On the flip side, a single-board computer can run multiple programs simultaneously just as a typical PC or mobile device would. Instead of uploading code to an SBC, various apps need to be installed on top of the OS in order to run. 

Single-board computer:

  • Runs an operating system with programs running on top of that
  • Capable of multi-tasking

Microcontroller:

  • Runs one program
  • Executes a singular task

What is the Difference Between a Microcontroller and a Microprocessor?

While microcontrollers and microprocessors are related, even outside of the micro in their names, the two devices are decidedly different. A microcontroller features a CPU, memory, and I/O integrated onto a single board. Comparatively, a microprocessor is, as its name suggests, just the CPU or central processing unit. Microprocessors are at the core of electronics such as PCs and mobile devices, whereas microcontrollers are utilized in embedded devices.

Microcontroller: Used in embedded devices. Contains a processor, memory, and I/O on a single board

Microprocessor: Only a CPU

What is an Example of a Microcontroller?

What is a Microcontroller - arduino nano

The most prominent example of a microcontroller is the Arduino. There are loads of different Arduino boards that are suitable for a variety of purposes. The Arduino Uno R3 is a good multi-purpose microcontroller, and the aptly-named Arduino Every is a great MCU for general use. Specialized Arduino boards such as the Arduino Nano 33 BLE and Arduino Nano 33 IoT cater to low-power Internet of Things projects. 

Additionally, you'll find loads of Arduino alternatives. The Brainfuino, Lilypad Arduino, Diavolino, and NodeMCU are all Arduino Integrated Development Environment (IDE) compatible MCUs. Adafruit carries a slew of excellent microcontrollers such as its Circuit Playground Express, Feather ESP32, and Adafruit Feather ESP8266. 

Examples of microcontrollers:

  • Arduino Uno R3
  • Arduino Nano 33 BLE/Arduino Nano 33 IoT
  • Arduino Every
  • Circuit Playground Express
  • Adafruit Feather ESP8266/Adafruit Feather with ESP32
  • Lilypad Arduino

What Types of Microcontrollers Exist?

You'll generally find three main varieties of microcontrollers defined by their microprocessors: 8-bit, 16-bit, and 32-bit. An 8-bit microcontroller is very low-power, both in terms of computing power and energy efficiency. Typically, 8-bit MCUs are compatible with the Arduino IDE but can't be programmed with more advanced frameworks such as MakeCode or CircuitPython. The ATtiny85 is an 8-bit microcontroller which accordingly features an 8-bit CPU clocked at 8MHz. The ATmega328P is an 8-bit microcontroller typically running at 16MHz. 

32-bit microcontrollers are faster and more powerful, yet still energy efficient. Not only is the 32-bit processor in a 32-bit MCU beefier, but 32-bit microcontrollers hold the advantage of being able to handle more RAM and flash memory, along with higher clock speeds. For example, you'll find many 32-bit MCUs such as the SAMD21G which sport capable ARM Cortex M0+ processors and are clocked at 48MHz. With more I/O, RAM, flash memory, and significantly higher clock speeds, many 32-bit microcontrollers can handle advanced frameworks including CircuitPython and MakeCode. As such, there's more flexibility in how to program for 32-bit MCUs. 16-bit microcontrollers fall somewhere in between with more capabilities than 8-bit MCUs, and less processing power than 32-bit MCUs. 

Types of microcontrollers:

  • 8-bit
  • 16-bit
  • 32-bit

What can You do With a Microcontroller?

The possibilities are nearly endless with microcontrollers, but the general concept is controlling various connected devices. Although MCUs concentrate on one task and a running a single program, that doesn't mean a microcontroller is limited in what it can do. A program for a microcontroller can be complex or basic. 

For instance, some projects only have a single step such as blinking an LED. Commands in the code tell an MCU to power on and off a pin at a certain interval. But stringing commands together allows for complicated, multi-step applications. 

A microcontroller can power a smart watering system that incorporates an LCD screen moisture sensors, and a water pump. Then, a program written for that MCU monitors moisture levels and when a certain threshold is reached, it activates the pumps. Once the required moisture level is achieved, the pumps shut off. It's still a single task and one program, but there are several different steps.

In general, microcontrollers are great for Internet of Things and embedded projects. Controlling peripherals such as blinking LEDs and powering servos works well with MCUs, as does building smart watering systems, creating robotics, and more.

Best microcontroller applications:

  • Smart home projects (i.e. security systems, attendance monitors, smart gardening, etc.)
  • Controlling peripherals (i.e. blinking LEDs, controlling servos, etc.)
  • Wearable tech (cosplay, fitness wearables, etc.)
  • ...and more!

How to Pick Out the Best Microcontroller for Your Needs

There are loads of microcontrollers available. Finding the right MCU depends on your needs. Price is one consideration, though most MCUs are fairly inexpensive. What frameworks you want to run and compatible programming is key. While many microcontrollers feature Arduino IDE compatibility, others might work with CircuitPython, MakeCode, and other platforms. And use case is key. What MCU you'll want for integration into wearable devices differs from a good microcontroller for a smart home project.

What to look for in a microcontroller:

  • Price
  • Size/shape
  • Framework/programming compatibility (Arduino IDE, CircuitPython, MakeCode, etc.)
  • Use case (wearables, smart home tech, etc.)

What is a Microcontroller - Final Thoughts

Overall, a microcontroller is very different from a single-board computer. MCUs complete one task and run a single program, whereas SBCs can multi-task. Microcontrollers are typically extremely low energy yet fan pack pretty decent processing power. And the possibilities are pretty much limitless of what you can do with a microcontroller. There are loads of different MCUs to choose from, ranging from Arduinos to Adafruit microcontrollers. Ultimately, adding a microcontroller to your collection opens up tons of possibilities for making. 

Your turn: What microcontrollers are you using and what have you made recently with an MCU?

Leave your feedback...