Line | |
---|
1 | /*
|
---|
2 | Melody
|
---|
3 |
|
---|
4 | Plays a melody stored in a string.
|
---|
5 |
|
---|
6 | The notes and durations are encoded as follows:
|
---|
7 |
|
---|
8 | NOTES:
|
---|
9 | c play "C"
|
---|
10 | C play "#C"
|
---|
11 | d play "D"
|
---|
12 | D play "#D"
|
---|
13 | e play "E"
|
---|
14 | f play "F"
|
---|
15 | F play "#F"
|
---|
16 | g play "G"
|
---|
17 | G play "#G"
|
---|
18 | a play "A"
|
---|
19 | A play "#A"
|
---|
20 | b play "B"
|
---|
21 | - silence
|
---|
22 |
|
---|
23 | DURATIONS:
|
---|
24 | 1 Set as full note
|
---|
25 | 2 Set as half note
|
---|
26 | 4 Set as quarter note
|
---|
27 | 8 Set as eigth note
|
---|
28 |
|
---|
29 | SPECIAL NOTATION:
|
---|
30 | . Make the previous note 3/4 the length
|
---|
31 |
|
---|
32 | Circuit:
|
---|
33 | * Arduino Robot
|
---|
34 |
|
---|
35 | created 1 May 2013
|
---|
36 | by X. Yang
|
---|
37 | modified 12 May 2013
|
---|
38 | by D. Cuartielles
|
---|
39 |
|
---|
40 | This example is in the public domain
|
---|
41 |
|
---|
42 | This code uses the Squawk sound library designed by STG. For
|
---|
43 | more information about it check: http://github.com/stg/squawk
|
---|
44 | */
|
---|
45 |
|
---|
46 | #include <ArduinoRobot.h>
|
---|
47 | #include <Wire.h>
|
---|
48 | #include <SPI.h>
|
---|
49 |
|
---|
50 | void setup() {
|
---|
51 | // initialize the robot
|
---|
52 | Robot.begin();
|
---|
53 |
|
---|
54 | // initialize the sound library
|
---|
55 | Robot.beginSpeaker();
|
---|
56 | }
|
---|
57 |
|
---|
58 | void loop() {
|
---|
59 | // array containing the melody
|
---|
60 | char aTinyMelody[] = "8eF-FFga4b.a.g.F.8beee-d2e.1-";
|
---|
61 |
|
---|
62 | // play the melody
|
---|
63 | Robot.playMelody(aTinyMelody);
|
---|
64 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.