Created
February 15, 2016 01:59
-
-
Save okn3/0d36f04d904365b5c9be to your computer and use it in GitHub Desktop.
arduinoピエゾスピーカーサンプル
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
| #define BEAT 300 // 音の長さを指定 | |
| #define PINNO 12 // 圧電スピーカを接続したピン番号 | |
| void setup() { | |
| } | |
| void loop() { | |
| tone(PINNO,262,BEAT) ; // ド | |
| delay(BEAT) ; | |
| tone(PINNO,294,BEAT) ; // レ | |
| delay(BEAT) ; | |
| tone(PINNO,330,BEAT) ; // ミ | |
| delay(BEAT) ; | |
| tone(PINNO,349,BEAT) ; // ファ | |
| delay(BEAT) ; | |
| tone(PINNO,392,BEAT) ; // ソ | |
| delay(BEAT) ; | |
| tone(PINNO,440,BEAT) ; // ラ | |
| delay(BEAT) ; | |
| tone(PINNO,494,BEAT) ; // シ | |
| delay(BEAT) ; | |
| tone(PINNO,523,BEAT) ; // ド | |
| delay(3000) ; // 3秒後に繰り返す | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考(音程)
https://fabkura.gitbooks.io/arduino-docs/content/chapter7.htmlhttps://fabkura.gitbooks.io/arduino-docs/content/chapter7.html