Chapter 2 (2nd Edition)

If you are looking for the Chapter 2 content for the 1st Edition of Exploring Arduino, please click here.

Digital Inputs, Outputs, and Pulse-Width Modulation

Parts List


Download Code (2nd Edition, Chapter 2)
(Also available on GitHub)

Useful Links


  • On page 46, the final else{} statement in listing 2-6 (rgb_nightlight.ino) for the RGB nightlight is supposed to turn the nightlight off. Because the RGB LED is common anode, this should be done by setting all the cathode pins HIGH, but the printed code sets them all LOW by mistake. This issue has been resolved in the downloadable code for this chapter. (GitHub Issue Details)
  • On page 46, the closing curly bracket is missing from the loop() function of code listing 2-6 (rgb_nightlight.ino). The downloadable code correctly includes the missing bracket – the issue is only in print.


This video will teach you about digital inputs/outputs, debouncing, and PWM:

This video will teach you the basics of electrical and computer engineering: