Intro to Output
Table of Contents
- Lessons
- Lesson 1: Turning on an LED
- Lesson 2: Blinking an LED with
digitalWrite() - Lesson 3: Debugging with
Serial.println - Lesson 4: Fading an LED with
analogWrite() - Lesson 5: Playing Sounds with
tone() - Lesson 6: Blinking an LED Part 2
- Lesson 7: RGB LEDs
- Lesson 8: Crossfading RGB LEDs
- Lesson 9: Rate Blinking Multiple LEDs
- What’s next?
In this lesson series, you will learn how to programmatically control Arduino’s GPIO pins to drive LEDs, produce colors with RGB LEDs, generate tones with piezo buzzers, and build your first C++ class. We start with the basics—powering an LED from Arduino’s supply pins—and progressively introduce 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().
The lessons are interactive and designed to be completed in order. All Arduino code is open source and in this GitHub repository.
Before starting, make sure you have the Arduino IDE installed and have reviewed the Arduino Uno vs. Leonardo section. If you’re new to electronics, we recommend completing Intro to Electronics first.
Lessons
Lesson 1: Turning on an LED
You’ll build your first LED circuit using Arduino’s power and ground pins, learn about current-limiting resistors, and get hands-on experience plugging components into the Arduino.
Lesson 2: Blinking an LED with digitalWrite()
You’ll write your first Arduino program to programmatically control a GPIO pin, turning an LED on and off using digitalWrite.
Lesson 3: Debugging with Serial.println
Introduces some basic debugging approaches for Arduino, with a specific focus on Serial.print.
Lesson 4: Fading an LED with analogWrite()
Introduces analog output, pulse-width modulation (PWM), and demonstrates how to gradually fade an LED on and off by using analogWrite.
Lesson 5: Playing Sounds with tone()
Explores how to generate square waves of varying frequencies to play sounds and melodies using a piezo buzzer and the tone() function.
Lesson 6: Blinking an LED Part 2
Explores the difference between current sourcing and current sinking by hooking up two LED circuit configurations: one with the LED anode facing the I/O pin (current source) and another with the LED cathode facing the I/O pin (current sink).
Lesson 7: RGB LEDs
Introduces RGB LEDs, using both common anode and cathode versions, and controlling color output with digitalWrite.
Lesson 8: Crossfading RGB LEDs
Shows how to fade between RGB colors using analogWrite, to use the HSL colorspace to more easily (and independently) control hue and brightness, and to use and load local C/C++ libraries.
Lesson 9: Rate Blinking Multiple LEDs
You’ll learn how to blink multiple LEDs at different rates and build your first C/C++ class, which will greatly simplify your code and reduce its size by eliminating redundancy.
What’s next?
Once you’ve completed the Output lessons, move on to Intro to Input to learn about buttons, sensors, voltage dividers, and more!