Different realms of computing
Share
Explore

icon picker
Embedded electronics / internet of things / microcontrollers

Embedded electronics / internet of things / microcontrollers

What is this?

Every electronic device from a microwave to a smart speaker to a video game controller to an industrial sensor in a meat warehouse needs a small processor inside to control its behavior, display something on a screen, know what buttons a user pressed, etc.
Smart home devices and industrial sensors are part of the “internet of things” because they also have code to connect to the internet to send some information (sensors) or to get some information (this is how your Alexa speaker plays a song - it streams the song from Amazon’s servers).

Common coding languages used in industry

C/C++
Python
Micropython (this is extremely new - since 2016, so it’s not that common yet).
Not by any means a standard, but some companies do use it because it helps them quickly make functioning products.
Circuitpython (this even newer than Micropython. It is much easier to use than Micropython. Circuitpython was missing too many essential features prior to version 7. Version 8 is almost out of beta and is the first version I would use for anything serious).
Circuitpython is organized by Adafruit, which is an electronics parts retailer. The documentation and standardization is better than for Micropython.
The community is very good.

Common software libraries used in commercial products

mbed
C++ library for a variety of more-professional microcontrollers.
Allows for scheduling tasks to feel like they run in parallel using interrupts (RTOS).
Has good community-made libraries for a lot of accessories/sensors.
Supported by ARM which is the company that designs the microprocessors in these boards and also in smartphones.
Has a web-based editor (so it would theoretically work on Chromebooks)
freeRTOS
C++ library for a variety of more-professional microcontrollers.
Allows for scheduling tasks to feel like they run in parallel using interrupts (RTOS).
Super barebones.
Zephyr
C++ library for a variety of more-professional microcontrollers.
Allows for scheduling tasks to feel like they run in parallel using interrupts (RTOS).
Somewhere in-between freeRTOS and mbed
I would not try to teach high schoolers any of these. More complicated than it needs to be. If you attempted any of these, mbed is probably the easiest.

Common software libraries used by education/hobbyists but not by industry

Arduino
Arduino is not a coding language. It is a set of libraries (code that someone else has written and shared with others to use). The actual coding language Arduino uses is C++.
Easy to get started with simple things, but doesn’t make it easy to use event-based programming, interrupts, timers, etc. (which are really fundamental building blocks).
Lots of libraries for common devices.
The Arduino IDE (the app used to write code for Arduino) is nice to get started but becomes a pain for any project longer than 30 lines of code (which is almost every project). The Arduino IDE 2.0 is much more usable.
MakeCode
Block-based coding.
It actually supports events/interrupts.
It does some weird thing where the blocks are converted to Javascript or Python and then converted to C++
Has very little community and library support for accessories/sensors
Scratch
Block-based.
No interrupts
Even worse library support. No company will invest time making a library for something that so few people use.
Please don’t use

Important concepts for high schoolers to learn

Be able to make something useful and fun (Examples: internet-connected sensors, or portable games, or interactive museum exhibits)
Reading in sensor inputs
Digital (Ex. buttons, some knobs, accelerometers/gyroscopes, temperature sensors, time-of-flight sensors, etc)
Analog (Ex. photoresistors to sense brightness, some knobs, certain temperature sensors)
Outputting to something meaningful
Digital (Ex. LEDs, Screens, Audio Amplifier, Motors, WiFi/bluetooth chips)
Analog (Ex. Low-quality sounds, specific waveforms or voltages for some other device)
Communication methods
GPIO (toggling pins)
PWM (toggle a pin really fast to change the average voltage. Usecases: Make a motor move at different speeds, make an LED shine at different brightnesses, output a constant voltage between 0 and max voltage using a capacitor to smooth the voltage)
SPI / I2C / Serial UART (know that these exist and conceptually a little bit how it works. They can use code libraries that hide how it actually works. Usecases: connect a screen, temperature sensor, wifi chip)
WiFi / Bluetooth (send or receive data from the internet, send notifications to a phone, communicate with another microcontroller such as with a security alarm system or multiplayer video game)
That most electronics literally just toggle things on and off at different speeds
Interrupts / Timers / Event-based programming
“If I press a button, then change this setting”
“Blink red LED 1 time per second, Blink green LED 7 times per second, etc”
Planning your code before you write it
Writing pseudo code, doing small tests before writing the whole thing
Thinking about structs to keep code neat and functions
Calculations and signal processing
Ex. Calculating: number of button presses, how high a video game character should jump, if two elements on a screen are about to collide
Ex. Signal processing: take an average reading of an input to filter out random noise or accidental button presses, look for specific patterns on a motion sensor to detect a person
How to debug
How to identify the line causing a problem
Ideally using a debugger software that allows you to step line by line rather than using print statements.

Common code editor apps and IDEs

Hobbyist
Arduino IDE
easyish to get started with small test programs
Very clean, beginner-friendly interface
Does a good job making examples accessible
Does not give any hints as you type to help you complete your code
Installing new libraries and boards can be a major pain and cause confusing errors
Splitting code into multiple files works but is a bit weird.
VS Code + Arduino extension
It's good if you are already a bit familiar with VS Code (which can also be used for other types of coding including websites and python for data science)
It may look a bit daunting at first cause there are a lot of options, but most of the options can be ignored
You don't have to make a project folder and give it a name first before you can start coding.
Gives code suggestions as you type and tells you if you missed semicolons or have other errors before you compile and try to send to Microcontroller (but sometimes it highlights things that are perfectly fine)
Downloading additional libraries and boards seems easier and has a more performant UI than arduino IDE but this seems to be a bit buggy.
Has an option to save the build files so sending code to the board if you make a couple of changes is MUCH faster than with Arduino IDE
Hobbyist and pro
VS Code + PlatformIO
Great if you like VS Code
Simultaneously easier to use and harder to use than Arduino IDE
Easier - it automatically detects COM ports, provides code suggestions, has a get started wizard to set up nearly any type of board, and has a great library search engine, importing libraries from GitHub is just pasting the URL in a list (no need to download a zip)
Harder - has a ton of other options that young students don't really need to see, you can't just quickly open an example and run it, it exposes arduino code into C++ files (in the long-run this is a good thing though), occasionally you have to type JSON or YAML to change settings which can be an odd learning curve
Includes an awesome debugger for microcontrollers that support it (like the microbit)
Supports a variety of frameworks including arduino, mbed, Zephyr, FreeRTOS, etc
Used by professionals and university students and a few high schools
They have a web-based editor
Sending code to a device is easy: the microcontroller looks like a flash drive. You download a file from the editor and drop it in the microcontroller
They actually have 2 editors: mbed online and mbed Studio (which is based on Theia which is based on VS Code). Studio is a new thing and is in constant development.
Studio is Supposed to have a good debugger
I've never used Studio

Read next:

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.