No products in the cart.
This Arduino tutorial will use a photoresistor and a piezo buzzer to create a buzzer for your dog door to know when your best friend comes and goes. A photoresistor is a light-controlled variable resistor whose resistance decreases with exposure to light. As your dog passes through the door, the photoresistor’s resistance will decrease and cause thepiezo buzzer to sound.
1 Arduino Board
1 Piezo Buzzer
1 10K ohm resistor
1 6” USB A/B cable
- Start off by placing your photoresistor on the breadboard. Connect a wire from the 5V source to the photoresistor. Place a 10k Ω resistor on the other pin of the photoresistor. Connect a wire from the resistor to the A0 pin and a wire from the other leg of the resistor to the ground of your Arudino board.
- Connect a wire from digital pin 7 to the piezo buzzer on the breadboard. Be sure to ground the Piezo Buzzer.
- Open the Arduino software and create a new sketch; then upload the code below into the sketch:
void buzz(unsigned char time)
4.Connect a USB A/B cable from your computer to the Arduino. Click “Upload” in the Arduino program to run your sketch.
5.To test your code, cover the photoresistor to buzz the piezo buzzer.