Intro to Arduino
Table of Contents
- Why this Learning Series?
- Arduino Uno R3 vs. Arduino Leonardo
- Arduino uses C++
- Intro to Output
- Intro to Input
Welcome π to the second module in your Physical Computing journey: Introduction to Microcontrollers using Arduino. Here, you will learn about digital output, analog output, digital input, and analog input and build interesting musical instruments along the way from a button piano to a Jedi-force instrument! Get started with our first lesson: L1: Turning on an LED and start building! βπ
New to this interactive textbook? While you can start here (with learning Arduino, woohoo! π₯³), we highly recommend completing Intro to Electronics first. We frequently build on fundamental concepts from that moduleβlike voltage, current, resistance, and circuit analysisβwithout re-explaining them here.
Why this Learning Series?
There are many Arduino resources online, many good, some bad. Our two favorites are, perhaps, Adafruitβs 18-Step Guide and Jeremy Blumβs Exploring Arduino: Tools and Techniques for Engineering Wizardry, 2nd Edition, Wiley, 2020. See our Resources page for more.
Our lessons are different both in approach and scope. They are based on years of experience in teaching physical computingβto design students, computer scientists, and engineers at the undergraduate and graduate levelβand we attempt to address common confusions head-on.
Thus, while other resources start with digital/analog input (or quickly intermix input and output), weβve found that itβs easier to start with output. For novices, input is simply harderβit requires an understanding (or at least an awareness) of concepts like pull-down resistors, voltage dividers, and that a microcontroller reads voltages rather than current or resistance.
So, our lessons start and stick with output to solidify understanding of how to programmatically control microcontroller pins before adding in inputβwhere the fun, of course, really starts! Moreover, most resourcesβat least those we are aware ofβstrike a different balance between depth and breadth. We love Adafruitβs tutorials but they tend towards step-by-step construction recipes rather than explaining why or how things work. As a college-level resource, we attempt to provide a deeper understanding at a cost of complexity and longer lessons. But we think itβs worth it.
Arduino Uno R3 vs. Arduino Leonardo
For this introductory lesson series, we use two of the most popular 5V Arduino models: the Arduino Uno Rev3 and the Arduino Leonardo; however, the lessons themselves should translate to almost any Arduino boardβwhich is the beauty of the Arduino hardware-software ecosystem!

Both the Uno and Leonardo have similar form factors, memory, clock speeds (16MHz), and GPIO pins (20 digital I/O pins); however, there are some differences:
-
The Uno uses the ATmega328P microcontroller while the Leonardo uses the ATmega32u4
-
The Leonardoβs ATmega32u4 has built-in USB support whereas the Uno actually has a second microcontroller (the ATmega16U2) to provide USB communication. On the Uno, pins 0 and 1 are used to communicate with the 16u2 co-processor, which can conflict with components plugged into those pins (so our examples will often avoid using pins 0 or 1, even on the Leonardo)
-
Because the Leonardo natively supports USB, it can be mounted as a Human Interface Device (HID) and thus used as a mouse, keyboard, or joystick.
-
The Leonardo has 12 analog inputs vs. the Unoβs 6
-
The Uno has series reverse-polarity protection on its barrel jack, which drops the voltage by ~0.7V but safely protects the board if a power supply is plugged in backward. The Leonardo wires the barrel jack directly to
VIN(no voltage drop, better for high-current loads like servos) but uses a parallel shunt diode for protection. If you plug an unprotected battery pack into the Leonardo backward, it will likely destroy the diode and the board. See Reverse Polarity Protection: Uno vs. Leonardo.
A Note on the Arduino Uno R4 Released in June 2023, the Arduino Uno R4 (available in βMinimaβ and βWiFiβ versions) is a significant hardware leap from the R3 while maintaining the same physical footprint and 5V operating voltage. It upgrades from an 8-bit AVR chip to a 32-bit ARM Cortex-M4 microcontroller, boasting a 48 MHz clock speed (3x faster), vastly expanded memory (256 kB Flash, 32 kB SRAM), a modern USB-C connector, and a true built-in DAC for actual analog output. Because it maintains backward compatibility, the code and concepts in these lessons translate perfectly to the R4!
In the lessons themselves, weβll mark specific differences between the Uno and Leonardo, when relevant.
Arduino uses C++
Before we begin, a note about Arduinoβs programming language.
Arduino programsβaka βsketchesβ in Arduino parlanceβare written in standard C++ (which inherently supports C). When you compile a sketch, the Arduino IDE processes the code and feeds it to a standard GNU C++ compiler (such as avr-g++ for traditional AVR boards or an ARM equivalent for newer ones).
What is often referred to as the βArduino languageβ is simply C++ combined with the Arduino core libraries. These libraries provide the built-in functions (like digitalWrite(), analogRead(), etc.) and the hidden main() function that calls your setup() and loop(), abstracting away the raw microcontroller register manipulations.
Programming background In our lessons, itβs helpful to have some programming experience, especially with a typed, compiled language like C++, Java, C#; however, it is not absolutely necessary. The programming requirements in the intro lessons are relatively minor though you should know how to use loops, conditionals, functions, variables, and more. As we move to the more advanced lessons, we expect stronger programming background.
Now, let the fun begin! ππ₯³
Intro to Output
π¦ Start Here! We highly recommend completing the Output lessons first to build a solid foundation before moving on to the Input series. Weβve learned from years of teaching this material that output is easier to start with than input!
In the Output lesson series, you will learn how to programmatically control Arduinoβs GPIO pins to drive LEDs, produce colors with RGB LEDs, generate sounds with piezo buzzers, and build your first C++ class. Topics include digital output (digitalWrite), debugging with Serial.print, analog output (analogWrite and PWM), sound generation (tone), current sourcing vs. sinking, and multi-rate blinking without delay().
All Arduino code is open source and in this GitHub repository.
Intro to Input
In the Input lesson series, you will learn about digital and analog input using buttons, potentiometers, and force-sensitive resistors. Youβll build musical instruments along the wayβfrom a button piano to a Jedi-force instrument!