Introduction: Light Sensor Buzzer

Picture of Light Sensor Buzzer

In this experiment we are going to work with a sensor which is a resistor that depends on light. In a dark environment, the resistor will have a very high resistance. As photons light lands on the detector, the resistance will decrease. The more light is we will have a lower resistance. By reading different values from the sensor, we can detect if is it light , dark or a value between them. Another element that we are going to use on this experiment is Buzzer.

Step 1: Circuit Setup and Beadboard

Picture of Circuit Setup and Beadboard

The schematic consists on 3 elements which are: Photoresistor (LDR), Piezo Buzzer, 1 – 10 kΩ. The LDR can be connected any way you want because it doesn’t have polarity. For resistance you can use from 1-10 KΩ because different LDR's have different settings. Try different values of resistor to fit the best settings with your LDR.

Step 2: Code

Picture of Code

int piezoPin = 8; // Declaring Piezo Buzzer on Pin 8

int ldrPin = 0; // Declaring LDR on Analog Pin 0

int ldrValue = 0; // Reading different values from the LDR

void setup

()

{ }

void loop()

{ // Starting the cycle functions below

ldrValue = analogRead(ldrPin); // read the value from the LDR

tone(piezoPin,1000); // Play a 1000Hz tone from the piezo (beep)

delay(25); // wait a bit, change the delay for fast response.

noTone(piezoPin); // stop the tone after 25 ms in this case

delay(ldrValue); // wait the amount of milliseconds in ldrValue} //

End of cycle functions

Step 3: Materials

Picture of Materials

1. Breadboard

2. Arduino Board

3. Male Wires

4. Resistors

5. Piezo Buzzer

6. Light Sensor

Step 4:

Picture of

Step 5:

Picture of

Comments

Swansong (author)2017-10-31

Thanks for sharing :)

About This Instructable

36views

0favorites

License:

More by Mjedwab:Light Sensor Buzzer
Add instructable to: