A Beginner's Guide to Microcontrollers
by jenfoxbot in Circuits > Microcontrollers
105937 Views, 724 Favorites, 0 Comments
A Beginner's Guide to Microcontrollers
What do remote controllers, routers, and robots all have in common? Microcontrollers! These days, beginner-friendly microcontrollers are easy to use and program with just a laptop, a USB cable, and some (free) open-source software. Woohoo!! All the projects, here we come!
The catch? There are like, 4324302* different microcontrollers and it can be daunting to get started, especially if you're just getting into electronics. Where the heck do you start?!
Right here, bbies, I got chu. Whether you are looking to build some cool electronic projects, learn programming/tech, or wanting to teach others about electronics, this tutorial will help you figure out what microcontroller is right for your needs, goals, and budgets. Yay! Let's get started!
Read Time: ~ 20 min
*Ok, ok, maybe not *that* many, but definitely a few dozen!
Wait.... What Is a Microcontroller?
Maybe you've seen this word and were like "wtf" but didn't feel comfy enough to ask*. Totally fine, here's a quick rundown:
A microcontroller is a "simple computer" that runs one program in a loop. They are designed to perform a single, specific task.
In this guide, we'll be focusing on microcontrollers that have breakout boards, or a board that makes it easier to connect to and program the microcontroller.
On a breakout board, the microcontroller pins are soldered to a printed circuit board ("PCB"), headers or other connectors are added to the PCB, and some basic firmware, or permanent software, is loaded to prep the microcontroller to receive signals.
*Questions are always good even if they are "dumb" or "n00by", just find a safe space -- like Instructables!
What's the Difference Between the Raspberry Pi and a Microcontroller?
The Raspberry Pi is not only small and adorable, it is also a full-fledged computer! :D
Computers have microprocessors AND microcontrollers that work together to perform many tasks at once.
The microprocessor is what does the “heavy lifting” in a computer. It performs the instructions and calculations that make the computer work. Microprocessors are much faster than microcontrollers, but they need external resources like RAM, Input/Output ports, etc., whereas a microcontroller is typically self-contained.
Computers (which have inputs and outputs, storage, and processing) can run multiple programs at a time -- you can surf the Internet, reminisce with old photos, write a paper, and have like 1000 tabs open all at the same time! Microcontrollers... not so much. You can do one of those things, but not all.
To learn more about the Raspberry Pi, check out the last section of this tutorial!
Arduino (Uno)
A robust, open-source microcontroller and programming environment designed for beginners with some knowledge of circuits.
Recommended Ages: 12+ (or kids comfy with programming and algebra)
Difficulty: Intermediate
Average Cost: ~$35
There are lots of different types of Arduino boards. This is the Arduino Uno, the best fit for beginners! There are boards that are larger, smaller, wearable, and for specialty use cases like robotics.
Being familiar with Arduino boards and programming maps well to projects and careers in computer science, engineering, and design.
Hardware Features
- The Arduino Uno has 14 Digital Input & Output ("I/O") pins, 6 Analog I/O pins, 2 Power Out pins (3.3V and 5V), and 3 Ground (GND) pins.
- Power input can be anywhere from 5 to 12 VDC
- The ICSP headers allow you to connect a ton of different add-on boards called "shields".
- For example, you can add a WiFi shield to connect your Arduino to the 'net!
Programming Language: Wiring (Combo of C++/Processing)
Example Project: Motion-Reactive Shake the Maze Game!
Purchase/Learn More: Arduino Website
Micro:Bit
A friendly lil’ microcontroller handy for kids and folks just getting started with coding and hardware.
Recommended Ages: 8+ (or kids comfy with circuits and simple tools)
Difficulty: Beginner
Average Cost: ~$15
The Micro:Bit is a great tool to start learning how to code, teaching others, particularly elementary school students, how to code, and making simple and quick electronic prototypes.
The Micro:Bit is a collaboration between Microsoft and the BBC to bring educational computers into classrooms around the world.
Hardware Features:
- The Micro:Bit has 3 Digital and Analog I/O pins, 1 Power Out pin (3.3V), and 1 Ground (GND) pin
- Power input should be 3 - 5 VDC via micro USB cable or battery pack connector.
- It also has lots of onboard inputs, outputs, and sensors!
- 5x5 (25) LED matrix
- Two (2) Pushbuttons (A, B)
- Radio Transmitter and Receiver
- Accelerometer
- Compass
- Light and Temperature Sensors
- For more I/O pins, grab a Micro:Bit breakout!
Programming Language: Block-Based or Javascript (www.MakeCode.org); can also use CircuitPython
Example Project: Text Messenger Puppet!
Purchase/Learn More: Micro:Bit Website
Circuit Playground Express
A versatile microcontroller great for kids and folks just getting started with coding and hardware.
Note: There is also the Circuit Playground Classic -- the hardware is nearly identical, but this board is programmed in the Arduino IDE.
Recommended Ages: 8+ (or kids comfy with circuits and simple tools)
Difficulty: Beginner
Average Cost: ~$25
The Circuit Playground Express, or CPX, is a helpful tool to learn how to code, teach others how to code, and make quick prototypes for beginners to experts alike.
The Circuit Playground Express is a powerful and versatile microcontroller created by Adafruit Industries.
Hardware Features
- The CPX has 7 Digital/Analog Input & Output ("I/O") rings that are also capacitive touch!
- 1 "true" Analog I/O ring
- 2 Power out ring (3.3V)
- 3 Ground (GND) pins
- Power input should be 3 - 5 VDC via micro USB cable or battery pack connector.
- There are also tons of onboard inputs, outputs, and sensors!
- 10 Mini Neopixels (can be all colors)
- 2 Pushbuttons (A, B)
- 1 Slide Switch
- Infrared Transmitter and Receiver
- Can receive/transmit remote control codes, send message between CPXs, and act as a distance sensor
- Accelerometer
- Sound sensor and mini speaker
- Light and Temperature Sensors
Programming Language: Block-Based or Javascript (www.MakeCode.org); can also use CircuitPython and Wiring (Arduino IDE)
Example Project: Minecraft Gesture Controller!
Purchase/Learn More: Adafruit Industries
Makey Makey
An interactive introductory microcontroller great for young kids and folks new to electronics and coding, especially for those who want to play with technology without having to build circuits and code.
Recommended Ages: 5+ (or kids comfy with simple tools)
Difficulty: Beginner
Average Cost: ~$50
The Makey Makey is a great first step into electronics and technology -- no programming required! Connect alligator clips to the pads and then connect any somewhat conductive material, like hands, fruit, or metal objects, to trigger certain keyboard and mouse keys.
The Makey Makey is an Arduino-compatible board, meaning that you can also reprogram it using the Arduino Integrated Development Environment ("IDE").
Hardware Features
- The Makey Makey has six (6) capacitive touch pads on the front of the board:
- Four control the keyboard arrow keys,
- One controls the spacebar, and
- One controls the left mouse click.
- On the back of the board are header pins for more controls (also capacitive touch):
- Six (6) pins that map to letters,
- Four (4) pins that map to arrows,
- Two (2) pins that map to mouse keys, and
- One (1) pin that maps to the spacebar key.
- There are also three (3) general I/O pins, a 5V power pin, and a ground pin.
Programming Language: Not applicable for beginners; can write Scratch programs (block-based); can reprogram in Wiring (Arduino IDE)
Example Projects
Beginner: Floor Piano
Intermediate: Interactive Survey Game!
Purchase/Learn More: Makey Makey website
Other Common Boards
There are waaaay too many microcontrollers to cover in one tutorial. If you have a super specific specialty need, there is probably a microcontroller for that (just like apps!). To get a feel for some of the other boards not mentioned in this tutorial, peruse the inventories of SparkFun Electronics and Adafruit Industries and/or ask folks in the field!
Here are a few of my favs:
Particle Photon
Similar to the Arduino Nano, the Photon is a WiFi connected microcontroller that can be programmed wirelessly. The easiest setup uses a (free) smartphone app, but if can also be programmed directly via USB in almost the same language as Arduino*.
Recommended Ages: 12+ (or kids comfy w/ circuits and coding)
Difficulty: Intermediate
Cost: ~$20
For more info and to get the Photon setup, visit the Particle online store here.
Programming Language: Wiring (more or less)
Example Project
*Wiring is the code framework, so most Arduino code will work without modifications. Can also write in C/C++ or ARM assembly
Adafruit HUZZAH ESP8266 Breakout
A super small, super cheap (and currently very popular in the IoT* community) WiFi microcontroller. You'll need an FTDI or console cable. You can use the Arduino IDE to program this board or NodeMCU's Lua Interpreter.
Recommended Ages: 14+ (or kids comfy w/ hardware & software)
Difficulty: Intermediate++
Cost: ~$10
For more info, visit the HUZZAH Adafruit product page.
(SparkFun also has a similar board, the "ESP8266 Thing", which you can find here for ~$15.)
Programming Language: Lua (sorta like Python) or Wiring (Arduino IDE)
*IoT stands for "Internet of Things", which is the term that refers to connecting and controlling various hardware devices, like sensors and household electronics, to the Internet.
Adafruit Trinket M0
A teeny tiny yet powerful microcontroller that blurs the lines between computer and microcontroller (it has an ATSAMD21E18 32-bit Cortex M0 processor). It can be programmed with Circuit Python or in the Arudino IDE.
Recommended Ages: 14+ (or kids comfy w/ hardware & software)
Difficulty: Intermediate
Cost: ~$9
For more info, visit the Adafruit product page for the Trinket M0.
Programming Language: CircuitPython or Wiring (Arduino IDE)
There are a TON of other M0 boards, similar in scope to the Arduino Zero connectable microcontrollers. If this doesn't suit your needs or your fancy, search around on the Adafruit and SparkFun websites!
Wearable Microcontrollers
There are also a handful of microcontrollers designed for wearable projects!
What makes these special is that they can be washed, so you don't have to rip them out of the awesome project you made (but do remove the battery!).
Wearable microcontrollers also have special I/O pins that make it easier to sew into clothing and stitch circuits with conductive thread. Here are a few of my favs:
Adafruit FLORA
A circular sewable microcontroller with 14 inputs and outputs. Can be washed (but def remove the battery).
Recommended Ages: 12+ (or kids comfy w/ circuits and coding)
Difficulty: Intermediate
Cost: $15
Programming Language: Wiring (Arduino IDE)
For more information, visit the Adafruit FLORA product page.
Arduino Gemma
A lil' tiny sewable microcontroller with 3 inputs and outputs. Perfect for hiding, connecting to small objects, and creating jewelry.
Recommended Ages: 12+
Difficulty: Intermediate
Cost: ~$5
Programming Language: Wiring (Arduino IDE)
For more information, visit the Arduino Gemma product page.
Arduino Lilypad
A circular sewable microcontroller with 14 available inputs and outputs.
Recommended Ages: 12+
Difficulty: Intermediate
Cost: ~$25
Programming Language: Wiring (Arduino IDE)
For more information, visit the SparkFun product page for the Lilypad.
Raspberry Pi 3
The Raspberry Pi, or Pi for short, is a credit-card sized computer* that runs a special version of Linux and can be programmed to control hardware.
Recommended Ages: 12+
Or kids comfy with coding and algebra
Difficulty: Intermediate (easy as a computer)
Average Cost: ~$35
The Raspberry Pi computer, or Pi for short, can be used as a “standard” computer or as a controller for all sorts of hardware projects. It is a great first computer for kids to use and learn to code on, and is widely used by hardware experts to build all sorts of electronic projects, from robots to 3D printers to home automation systems!
The Raspberry Pi has changed the way we build electronics! There are a few different versions, the most recent is the Raspberry Pi 3 and the Pi Zero, a miniature version of the Pi 3 for just $10.
Hardware Overview
- The recommended Operating System (“OS”) is a special version of Linux called Raspbian.
- The Pi has 40 General Purpose Input and Output (“GPIO”) pins.
- 26 Digital I/O pins (no Analog I/O)
- 4 Power Out pins (two 3.3V and two 5V)
- 8 Ground (GND) pins
- 2 Specialty Pins (I2C ID EEPROM, advanced use only)
- The Pi also has most standard computer features:
- 4 USB Ports
- 1 Ethernet port
- 1 HDMI port
- 1 Audio Jack
- 1 Camera Module Port
Programming Language (for GPIO pins): Python or C++
Since this is a full computer, you can program in whatever language you want, including programming other microcontrollers!
Example Projects
Purchase/More Info: Raspberry Pi Foundation
*The Pi can be used similar to a standard microcontroller AND can also control microcontrollers! Basically, the Pi is super awesome and I *have* to include it even tho it is technically a computer :)
Final Thoughts
If you are just getting started and want to build all sorts of projects, I'd recommend the Circuit Playground Express. It's super easy to get up and running and has a ton of onboard gadgets.
If you are super interested in computer networking, AI, or connecting things to the Internet (e.g. making a "Smart Home"), I'd suggest the Raspberry Pi.
If you want a sturdy, stable, and reliable board to build a wide variety of projects, go with an Arduino.
If you still have no idea where to start and are totally intimidated, start with the Micro:Bit -- it's only $15 and has plenty of snazzy things on it to play with. Plus, if you get one for your friend, you can send lil' messages back and forth :)
The best advice I can give you is to find a project you are passionate about and build it! There are tons of tutorials online so search around for someone who has built the same or similar project. Build off of their findings and adjust as you please!
And of course, leave any related questions in the comments and I'll do my best to help!
Happy hacking!