[Hindi / Urdu] Arduino Tutorial Buzzer with LDR and LED
Arduino basic tutorial for beginner. We will learn use buzzer, ldr and led with Arduino Uno.
Hardware Required:
- Arduino Uno
- Buzzer
- LED
- LDR
- 220 and 10K ohm resistor
- Wires
- Breadboard
Get the Code:
Get the 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");
}
}
You're a thief! Labor thief! I reported your channel to YouTube Copyright Agent! Your channel will be shut down!
ReplyDelete