Q.No.13 - WAP to interface LED and Buzzer with Arduino board keeping the condition that whenever LED glows, there is a Buzzer ringing and when LED is off then Buzzer is also put on off.
Sol.- Buzzer on when LED ON and vice versa.
int led=2;
int buzzer=7;
void setup()
{
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop()
{
digitalWrite(led, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
OUTPUT: