30 lines
467 B
C++
30 lines
467 B
C++
class BuzzerPin{
|
|
private:
|
|
int buzzerPin;
|
|
int button;
|
|
public:
|
|
BuzzerPin(int bp, int but){
|
|
buzzerPin = bp;
|
|
button = but;
|
|
pinMode(button, INPUT);
|
|
pinMode(buzzerPin, OUTPUT);
|
|
}
|
|
|
|
void activate(){
|
|
if(digitalRead(button) == HIGH){
|
|
digitalWrite(buzzerPin, HIGH);
|
|
}else{
|
|
digitalWrite(buzzerPin, LOW);
|
|
}
|
|
}
|
|
};
|
|
|
|
BuzzerPin buzzerOne(12, 20);
|
|
|
|
void setup(){
|
|
|
|
}
|
|
|
|
void loop() {
|
|
buzzerOne.activate();
|
|
} |