Last active
April 26, 2018 12:03
-
-
Save ikizoglu/967b72aaa1544bdbcd7bbe538b481726 to your computer and use it in GitHub Desktop.
Arduino Buton ile Buzzer Kullanımı
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ************************ | |
| // ** 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