やりたいこと
Arduino Unoと圧電スピーカでNHKのど自慢の鐘の音(合格した時のやつ)を出したい。
使うもの
- Arduino Uno R3(ここで実際に使用しているのはArduino Uno互換の DFRduino UNO R3)
- 圧電スピーカ(PT08-Z185)
配線
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#define PIN_TONE 8 void setup() { } void loop() { tone(PIN_TONE, 523, 300); delay(250); tone(PIN_TONE, 494, 300); delay(250); tone(PIN_TONE, 440, 300); delay(250); tone(PIN_TONE, 392, 300); delay(250); tone(PIN_TONE, 523, 300); delay(250); tone(PIN_TONE, 494, 300); delay(250); tone(PIN_TONE, 440, 300); delay(250); tone(PIN_TONE, 392, 300); delay(250); tone(PIN_TONE, 523, 900); delay(500); tone(PIN_TONE, 659, 900); delay(500); tone(PIN_TONE, 587, 900); delay(500); for(;;); } |