Arduino Light Sensor and Piezo Buzzer Experiment

Home Forums ARDUINO PROJECTS Arduino Light Sensor and Piezo Buzzer Experiment

This topic contains 0 replies, has 1 voice, and was last updated by  Sales 3 years, 11 months ago.

Viewing 1 post (of 1 total)
  • Author
  • #2265


    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) land 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 Piezo Buzzer.

    So what is it ?
    It’s an electronic device commonly used to produce and signaling a process that is happening through a sound, beep or etc. The Piezo buzzer produces sound through electricity. Some uses of Piezo Buzzer: e.g clock alarm, alarms, car/truck reversing indicator, bells, timers etc. So we see that this element is used on a wide area of electronic devices.

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

    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 

    After uploading the code the Piezo will start making short beeps. On bright light the Piezo will only beep and on dark light it will be short. Some ideas for this experiment: Alarm for Lights in the home. Solder 2 long wires to the LDR and put it to the light. When someone is turning on the light the Piezo will start immediately to beep.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.