Hardware Reference
In-Depth Information
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 modula-
tion 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, a key skill when reading human input. By the end of the chapter, you
will be able to build and program a controllable RGB (Red, Green, Blue) LED
nightlight.
NOTE YoucanfollowalongwithavideoasIteachyouaboutdigitalinputsand
outputs,debouncing,andpulse-widthmodulation(PWM): www.jeremyblum.com/
2011/01/10/arduino-tutorial-2-now-with-more-blinky-things/ .Youcan
alsofindthisvideoontheWileywebsiteshownatthebeginningofthischapter.
Ifyouwanttolearnmoreaboutsomeofthebasicsofelectricalengineering
touchedoninthischapter,watchthisvideo: www.jeremyblum.com/2011/01/17/
electrical-engineering-basics-in-arduino-tutorial-3/ .Youcanalso
findthisvideoontheWileywebsiteshownatthebeginningofthischapter.
DigitalOutputs
In Chapter 1, “Getting Up and Blinking with the Arduino,” you learned how to
blink an LED. In this chapter, you will further explore Arduino digital output
capabilities, including the following topics:
Setting pins as outputs
Wiring up external components
New programming concepts, including for loops and constants
Digital versus analog outputs and pulse-width modulation (PWM)
WiringUpanLEDandUsingBreadboards
In Chapter 1, you learned how to blink the onboard LED, but what fun is that?
Now it is time to whip out the breadboard and wire up an external LED to pin
9 of your Arduino. Adding this external LED will be a stepping-stone towards
helping you to understand how to wire up more complex external circuits in
 
Search WWH ::




Custom Search