In this example the photoresitor sends a on /off signal to an Arduino input dependent on ambient light conditions. When the Arduino detects darkness the LED is flashed.
- 1 x Arduino Board
- 1 x LED
- 1 x 220 Ohm resistor
- 1 x Photoresistor
- 1 x Solderless breadboard
To build the circuit, connect one end of the resistor to Arduino pin 12. Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the Arduino GND, as shown in the diagram and the schematic below.
After you build the circuit plug your Arduino board into your computer, start the Arduino IDE, and enter the code below.