Programming Examples

Arduino program to interface buzzer with LDR and LED


LDR Session in Arduino

Write Arduino program to interface buzzer with LDR and LED

Solution

void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(A0,INPUT);

}
void loop()
{
  	int signal;
  	signal=analogRead(A0);
  	Serial.println(signal);
  	if(signal>=400)
    {
  		tone(8,1000); 
      	digitalWrite(13,HIGH);
  		delay(100);
      	noTone(8);
      	digitalWrite(13,LOW);
      	delay(100);
      Serial.println("ALARM ACTIVATED");
    }  	
  	else
    {
      noTone(8);
      digitalWrite(13,LOW);
      Serial.println("ALARM DEACTIVATED");
    }
}
Output

LDR : Light Dependent Resistor 


Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2024 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz