Arduino

Page 75

Figure 5-5. Light-dependent resistor (LDR)

In darkness, the resistance of a light-dependent resistor (LDR) is quite high. When you shine some light at it, the resistance quickly drops and it becomes a reasonably good conductor of electricity. It is thus a kind of light-activated switch. Build the circuit that came with Example 02 (see “Using a Pushbutton to Control the LED” in Chapter 4), then upload the code from Example 02 to your Arduino. Now plug the LDR onto the breadboard instead of the pushbutton. You will notice that if you cover the LDR with your hands, the LED turns off. Uncover the LDR, and the light goes on. You’ve just built your first real sensor-driven LED. This is important because for the first time in this book, we are using an electronic component that is not a simple mechanical device: it’s a real rich sensor.

Advanced Input and Output

63


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.