// Q1 create a circit and wirte a program to produce beep sound with a buzzer using the class and object concept of c++
class Buzzer {
private:
int pin;
int beepDuration;
public:
Buzzer(int pin, int duration) {
this->pin = pin;
this->beepDuration = duration;
pinMode(pin, OUTPUT);
}
void beep() {
digitalWrite(pin, HIGH);
delay(beepDuration);
digitalWrite(pin, LOW);
delay(beepDuration);
}
void setBeepDuration(int duration) {
beepDuration = duration;
}
};
Buzzer buzzer(9, 500); // pin and delay
void setup() {
}
void loop() {
buzzer.beep();
delay(1000);
}