A Hacker's Guide to Programming Microcontrollers

A Hacker's Guide to Programming Microcontrollers

While hackers know and love the Raspberry Pi, many don't know of its cheaper cousin, the microcontroller. Unlike a Pi, which can be used more or less like a regular computer, microcontrollers like the Wi-Fi connected ESP8266 require some necessary programming skill to master. In this guide, we'll build an Arduino program from scratch and explain the code structure in a way anyone can understand.


Raspberry Pi vs. ESP8266


The Raspberry Pi is a small, single-board computer first created in the United Kingdom in 2012 that changed the way people thought about what a computer can be. With a massive community of loyal fans and excellent documentation, part of the magic of the Pi is how easy it is to get started. Aside from Raspberry Pi's unusual appearance compared to a traditional PC, it functions more or less like most of the computers you've used in the past.


The significant difference between a Raspberry Pi and a full-blown computer is mostly in the ARM processor the Raspberry Pi uses. Aside from that, the Pi will boot an operating system the same way most computers are expected to. Operating systems like Windows, Linux, and macOS provide intuitive interfaces for humans to interact with in real time, and this is one of the things that sets MCUs apart.


Rather than load an operating system, MCUs get right to business. Code that we write for the Arduino is loaded directly onto the device and runs each time we power it on. We write some code that tells the microcontroller to do something and then load those instructions onto the device using a program like ..