Active buzzer with LDR and LED- Arduino

in #utopian-io8 years ago (edited)

I just Wanted To Build A LDR Buzzer And Got Many Instructables Which Were Using To Do This Project.
20180107_132104.jpg

This arduino basic tutorial for beginner. We will learn use piezzo buzzer, ldr and led in Arduino board.

PARTS NEEDED IN THIS TUTORIAL

20180107_122624.jpg

  • Active buzzer
  • male to male jumpers
  • LDR
  • LED
  • uno board
  • 10k and 220 ohms resistors

  • CIRCUIT DIAGRAM

    ldr.png

    Just Follow The picture and the instruction i will give below icant upload fritzing diagram bcoz my pc cant install the app. Do The Wiring As Described In The Image
    You Will Get Your LDR Buzzer Circuit Ready In A Couple Of Minutes!
    20180107_123655.jpg

    Place the Buzzer, LDR and the LED to the vertical rail of the breadboard

    20180107_123942.jpg

    PU the 220 ohms resistor to the possitve leg of the LED the long leg should be the possitve, and the short leg will bw the GND negative..

    20180107_124326.jpg

    Wired the negtive GND of the parts, connect the short leg of the buzzer, the short leg of the LED, the left leg of the LDR, connect all that in one rail then connect it to the GND on the uno board.

    20180107_124854.jpg

    The right leg of the LDR to the 5v on the board, the long leg of the buzzer to the Digital pin 13.

    20180107_125125.jpg

    The last Connect the left leg of the 10k ohms resistor of the LDR to the pin Analog (A0) on the board.

    SOFTWARE

    Before we work on our sketch, make sure to download the Arduino IDE for your specific operating system. I’ll leave a link to where you can download this software: https://www.arduino.cc/en/Main/Software

    seq1.png

    Arduino Sketch code for Buzzer, LDR and LED, the led pin should be in pin 13, the buzzer in pin 12 and the lrdpin in analog pin 0

    buzz1.png

    CODE:

    //set pin numbers
    const int ledPin = 13;
    const int buzzerPin = 12;
    const int ldrPin = A0;
    void setup () {
      Serial.begin(9600);
      pinMode(ledPin, OUTPUT);
      pinMode(buzzerPin, OUTPUT);
      pinMode(ldrPin, INPUT);
    }
    void loop() {
      int ldrStatus = analogRead(ldrPin);  //read the state of the LDR value

      if (ldrStatus >= 400) {

        tone(buzzerPin, 100);
        digitalWrite(ledPin, HIGH);
        delay(100);

        noTone(buzzerPin);
        digitalWrite(ledPin, LOW);
        delay(100);

        Serial.println("----------- ALARM ACTIVATED -----------"); 
      }
      else {

        noTone(buzzerPin);
        digitalWrite(ledPin, LOW);

        Serial.println("ALARM DEACTIVATED");
      }
    }

    Compile and Upload The Code And BOOM! There You Go!
    You Just Made Your LDR Buzzer Without Any Hassles

    20180107_140141.jpg

    when connecting an LDR to Arduino board, one would automatically go for one of the Analog pins, which gives us an ON/OFF state instead of a value. when the light is ON the BUzzer start the tone and the LED start blinking, if we block the light passing thru the ldr the buzzer and LED should be deactivated as you can ob the GIF image below..

    20180107_132212.gif

    I was inspired by this blog so thats it for my little project today, ig you like this please upvote and follow me @pakganern
    20180105_182452.jpg



    Posted on Utopian.io - Rewarding Open Source Contributors

    Sort:  

    Thank you for the contribution. It has been approved.

    You can contact us on Discord.
    [utopian-moderator]

    Hah! Can't wait to restart playing with my own Particle Photon, Chip and Arduino. You made my day :)

    Your contribution cannot be approved yet. See the Utopian Rules. Please edit your contribution to reapply for approval.

    • Please provide the connection diagrams.

    You may edit your post here, as shown below:

    You can contact us on Discord.
    [utopian-moderator]

    already done sir!

    Hey @pakganern I am @utopian-io. I have just upvoted you!

    Achievements

    • This is your first accepted contribution here in Utopian. Welcome!

    Suggestions

    • Contribute more often to get higher and higher rewards. I wish to see you often!
    • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

    Get Noticed!

    • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

    Community-Driven Witness!

    I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

    mooncryption-utopian-witness-gif

    Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

    Coin Marketplace

    STEEM 0.08
    TRX 0.29
    JST 0.036
    BTC 101932.87
    ETH 3416.15
    USDT 1.00
    SBD 0.55