Skip to content

Instantly share code, notes, and snippets.

@samilkorkmaz
Last active February 8, 2020 19:01
Show Gist options
  • Save samilkorkmaz/da89314fba7d1b1324176423b633440b to your computer and use it in GitHub Desktop.
Save samilkorkmaz/da89314fba7d1b1324176423b633440b to your computer and use it in GitHub Desktop.
Button + buzzer with Arduino Nano
#define buttonPin 4
#define buzzerPin 3
void setup(){
Serial.begin(9600);
Serial.println("--- Hello :) ---");
pinMode(buttonPin, INPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
Serial.println("BUZZER HIGH");
digitalWrite(buzzerPin, HIGH);
} else {
Serial.println("BUZZER LOW");
digitalWrite(buzzerPin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment