Parts You'll Need for This Chapter:
1 10kΩ resistor
3 220Ω resistors
5mm single-color LED
5mm common-cathode RGB LED
CODE AND DIGITAL CONTENT FOR THIS CHAPTER
Code downloads, videos, and other digital content for this chapter can be found at www.exploringarduino.com/content/ch2.
In addition, all code can be found at www.wiley.com/go/exploringarduino on the Download Code tab. The code is in the chapter 02 download and individually named according to the names throughout the chapter.
Blinking an LED is great, as you learned in the preceding chapter, but what makes the Arduino microcontroller platform so useful is that the system is equipped with both inputs and outputs. By combining both, your opportunities are nearly limitless. For example, you can use a magnetic reed switch to play music when your door opens, create an electronic lockbox, or build a light-up musical instrument!
In this chapter, you start to learn the skills you need to build projects like these. You explore the Arduino's digital input capabilities, learn about pullup and pulldown resistors, and learn how to control digital outputs. Most Arduinos do not have analog outputs, but it is possible to use digital pulse-width modulation to emulate it in many scenarios. You learn about generating pulse-width modulated signals in this chapter. You will also learn how to debounce digital switches, ...