🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
Questions
























Write a program to interface LED and Buzzer with Arduino board, so that buzzer is put on whenever LED is on and Buzzer is put off when LED is off.

Last Updated : 13 Nov 2025

Solution:

void setup(){
    pinMode(2, OUTPUT);  // PIN 2 = LED
    pinMode(3, OUTPUT);  // PIN 3 = Buzzer
}

void loop(){
    digitalWrite(2, HIGH);  // Turn on the LED
    digitalWrite(3, HIGH);  // Turn on the Buzzer
    delay(5000);            // Wait for 5 seconds
    digitalWrite(2, LOW);   // Turn off the LED
    digitalWrite(3, LOW);   // Turn off the Buzzer
    delay(2000);            // Wait for 2 seconds
}
Report an error

Meanwhile you can watch this video

Watch Video
Latest Updates