User manual

4 Exit the Arduino IDE and start
Snap4Arduino again.
Christmas music
Components: 1x breadboard, 5x 20-Mohm resistor (red-black-blue), 6x connection cable, 6x clay contact, 1x piezo buzzer
The five clay contacts generate five different tones. Naturally, the Arduino can play any tones with the piezo buzzer. Many catchy tunes result
from five tones. Plus, these can easily be played with the five fingers of one hand without one having to switch the keys with the fingers.
Thus, for example, you can play the well-known Christmas tune "Jingle Bells":
Jin-gle bells, jin-gle bells
e e e e e e
jin-gle all the way
e g c d e
Oh what fun it is to ride in a
f f f f f e e e
one horse o-pen sleigh. Oh!
e d d d d g
Jin-gle bells, jin-gle bells
e e e e e e
jin-gle all the way
e g c d e
Oh what fun it is to ride in a
f f f f f e e e
one horse o-pen sleigh.
e d d d d
The programme
At the start, the programme defines five variables with the frequencies of the five tones used. Then an infinite loop waits for one of the clay contacts to
be touched. If this is the case, a tone is played and the programme waits for the contact to be released again. Then the tone is ended.
So that only one tone at a time can always be played, the clay contacts are queried in a loop in sequence and not in script blocks launched in parallel. It
is thus impossible for the program to attempt to play multiple tones at the same time.
Snap4Arduino offers the option to define your own blocks and execute JavaScript functions in order to thereby access the components defined in
StandardFirmata. The programme for Day 24 contains two such blocks:
To n e a t P i n . . . w i t h f r e q u e n c y . . . plays a tone with a specific frequency through a piezo buzzer that is connected to the stated pin.
Stop tone at Pin ... stops the playing of one tone and thus makes it possible to play a new tone. Before one tone can be played, the playing tone must
always be stopped first.