7 * 8-ohm speaker on digital pin 8
13 This example code is in the public domain.
15 http://arduino.cc/en/Tutorial/Tone
21 // notes in the melody:
23 NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
25 // note durations: 4 = quarter note, 8 = eighth note, etc.:
26 int noteDurations[] = {
30 // iterate over the notes of the melody:
31 for (int thisNote = 0; thisNote < 8; thisNote++) {
33 // to calculate the note duration, take one second
34 // divided by the note type.
35 //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
36 int noteDuration = 1000/noteDurations[thisNote];
37 tone(piezoPin, melody[thisNote],noteDuration);
39 // to distinguish the notes, set a minimum time between them.
40 // the note's duration + 30% seems to work well:
41 int pauseBetweenNotes = noteDuration * 1.30;
42 delay(pauseBetweenNotes);
43 // stop the tone playing:
49 // no need to repeat the melody.
50 // RESET to play again
54 1. Codificare Twinkle twinkle little star
55 2. Modificare lo script pitch follower (fotoresistenza + piezo)
56 per suonare una serie di beep durante la fase di calibrazione
57 e un breve motivetto (magari una scala crescente) per confermare
58 l'avvenuta calibrazione.
59 3. Codificare (magari utilizzando dei loop) qualche suono di allarme / conferma.