Chapter 2 (1st Edition)

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

Digital Inputs, Outputs, and Pulse-Width Modulation

Parts List

Code

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

Useful Links

Errata

Code errata listed below are corrected in the code downloads available from this page, and from github.

  • In numbered list on pages 26 and 27, there should be another step between steps 1 and 2: “100 is less than or equal to 1000, so the loop contents execute.” This makes the for loop description more clear.
  • In code listing 2-5, there is a missing closing bracket ( } ) following the “current = digitalRead(BUTTON);” line in early prints of the book. This has been fixed in later printings.
  • In code listing 2-6, the “if” statement for Purple should be an “if else” statement.

Color Wiring Diagrams

Videos

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

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