Skip to content

Instantly share code, notes, and snippets.

@ikizoglu
Last active April 26, 2018 12:03
Show Gist options
  • Select an option

  • Save ikizoglu/967b72aaa1544bdbcd7bbe538b481726 to your computer and use it in GitHub Desktop.

Select an option

Save ikizoglu/967b72aaa1544bdbcd7bbe538b481726 to your computer and use it in GitHub Desktop.
Arduino Buton ile Buzzer Kullanımı
// ************************
// ** Kemal İKİZOĞLU **
// ************************
int buton = 3; // Butonu 3.pinine atadık
const int buzzer = 2; // Buzzer'i 2.pine bağladık
int butonDurumu = 0; // Buton durumu 0 olarak başlayacak
void setup(){
pinMode(buzzer, OUTPUT); // Buzzer'ı 13.pinden çıkış aldık
pinMode(buton, INPUT); // Buton pinini giriş olarak kuruyoruz
}
void loop(){
butonDurumu = digitalRead(buton); // buton durumunu okuyoruz
if (butonDurumu == HIGH) { // eğer basılı ise
tone(buzzer,buton); // Buzzer çalacak
}
else{
noTone(buzzer); //Eğer buton basılı değilse ses yok
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment