CHAPTER 2
Digital Inputs, Outputs, and Pulse-Width Modulation
Parts You'll Need for This Chapter:
Arduino Uno
Small breadboard
Jumper wires
1 10kΩ resistor
3 220Ω resistors
USB cable
Pushbutton
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, ...
Get Exploring Arduino: Tools and Techniques for Engineering Wizardry now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.