Using buzzer with two pushbutton

preview_player
Показать описание
kod yorumdadir
Рекомендации по теме
Комментарии
Автор

const int buttonPin = 2;
const int buzzerPin = 3;
const int button2Pin = 4;
int buttonState = 0;
int button2State = 0;

void setup() {
Serial.begin(9600);
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(button2Pin, INPUT);
}

void loop(){

buttonState = digitalRead(buttonPin);
button2State = digitalRead(button2Pin);

if (buttonState == HIGH) {
Serial.print("zil caldi");

digitalWrite(buzzerPin, HIGH);
for (int i=0;i<25;i++){
analogWrite(buzzerPin, i*10);
}
a
else if (button2State == HIGH) {
Serial.print("Diger zil caldi");

digitalWrite(buzzerPin, HIGH);
for (int i=0;i<25;i++){
analogWrite(buzzerPin, i*10);
}





delay(100);
}
else {
digitalWrite(buzzerPin, LOW);
}
}

emreguvercin