Arduino - Buzzer With LDR and LED

by MertArduino in Circuits > Arduino

79860 Views, 71 Favorites, 0 Comments

Arduino - Buzzer With LDR and LED

Arduino Basic Tutorial 08 - Buzzer with LDR and LED

In this project; we will see using LDR to activate a buzzer and an LED. When light shines on LDR; the buzzer will give alarm and the LED will flash.

Hardware Required

vlcsnap-2016-11-16-04h49m58s668.png

  • Arduino Uno
  • Buzzer
  • LED
  • LDR (photoresistor)
  • 220 and 10k ohm resistor
  • Wires
  • Breadboard

Buzzer - LED - LDR Attach to Board

vlcsnap-2016-11-16-04h50m16s945.png
vlcsnap-2016-11-16-04h50m31s146.png
vlcsnap-2016-11-16-04h50m44s521.png
vlcsnap-2016-11-16-04h51m09s299.png
vlcsnap-2016-11-16-04h51m33s867.png
vlcsnap-2016-11-16-04h51m46s633.png
vlcsnap-2016-11-16-04h52m33s508.png
vlcsnap-2016-11-16-04h52m42s388.png
vlcsnap-2016-11-16-04h53m09s276.png
vlcsnap-2016-11-16-04h53m28s420.png
  1. Buzzer attach to board (the buzzer long leg (+) and short leg (-))
  2. LED attach to board (the LED long leg (+) and short leg (-))
  3. 220 resistor attach to board from LED long leg (+)
  4. LDR attach to board
  5. 10k resistor attach to board from LDR one leg

Arduino Connection

vlcsnap-2016-11-16-04h59m59s160.png
vlcsnap-2016-11-16-04h53m52s128.png
vlcsnap-2016-11-16-04h54m52s192.png
vlcsnap-2016-11-16-04h55m15s134.png
vlcsnap-2016-11-16-04h55m27s474.png
vlcsnap-2016-11-16-04h56m03s962.png
vlcsnap-2016-11-16-04h56m15s083.png
vlcsnap-2016-11-16-04h56m31s490.png
vlcsnap-2016-11-16-04h56m43s455.png
vlcsnap-2016-11-16-04h57m12s920.png
vlcsnap-2016-11-16-04h57m41s613.png
vlcsnap-2016-11-16-04h57m59s253.png
vlcsnap-2016-11-16-04h58m12s113.png
vlcsnap-2016-11-16-04h58m30s685.png
vlcsnap-2016-11-16-04h58m49s704.png
vlcsnap-2016-11-16-04h59m05s090.png
vlcsnap-2016-11-16-04h59m39s153.png

  1. The wire connect to ground, then the same wire attach to board.
  2. The wire connect to buzzer short leg, then the same wire attach to GND on the board.
  3. The wire attach to LED short leg, then the same wire connect to GND on the board.
  4. The wire connect to 10k resistor empty leg, then the same wire connect to GND on the board.
  5. The wire connect to +5V, then the same wire attach to LDR empty leg.
  6. The wire connect to digital 12, then attach to buzzer long leg.
  7. The wire connect to digital 13, then attach to 220 resistor empty leg.
  8. The wire connect to A0, then attach to LDR's - resistor's same column.

Code

vlcsnap-2016-11-16-05h00m18s478.png
vlcsnap-2016-11-16-05h00m47s926.png

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);

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");

}

}

If It Helps, Please Subscribe

vlcsnap-2016-11-16-05h00m55s649.png

First of all, I would like to thank you for reading this guide ! I hope it helps you.

If you want to support me, you can subscribe my channel and watch my videos.

Mert Arduino Tutorial & Projects