とりあえず起動音
とりあえずこんな感じで。
/* pipo2 / Arduino22 Arranged by OkibWorksLabo 2011/06/17 The circuit: * Speaker attached from pin 14 to ground (thru ~1K resistor as needs) * pushbutton attached to pin 2 from GND */ int buttonState = 0; const int pushBtn = 2; const int soundpin = 14; void setup() { pinMode(pushBtn, INPUT); digitalWrite(pushBtn, HIGH); pipo(); } void loop() { buttonState = digitalRead(pushBtn); if(buttonState == LOW) { pipo(); } } void pipo() { tone(soundpin, 4000); delay(100); tone(soundpin, 2000); delay(100); noTone(soundpin); delay(20); }
起動時に 1回「ぴぽ」言うて、そのあとは digital 2ピンを LOW に落とすと鳴ります。