Arduino Function: RobotControl.playMelody

Description

Plays a melody based on a string of music notes. The input string also contains information about note duration. The string can also contain pauses. This method must be preceded by Robot.beginSpeaker() in setup().

Syntax

Robot.playMelody(melody)

Parameters

melody: A string of notes to be played and their duration. The string may contain following chars, representing a note: *c : play "C" *C : play "#C" *d : play "D" *D : play "#D" *e : play "E" *f : play "F" *F : play "#F" *g : play "G" *G : play "#G" *a : play "A" *A : play "#A" *b : play "B" *- : silence Duration, represents the tempo used to play the note: *1 : Set the following as full notes *2 : Set the following as half notes *4 : Set the following as quarter notes *8 : Set the following as eigth notes *. : Set the note duration as its duration plus an half of its duration (Example 1/4 + 1/8)

Note

When a melody is playing, all other processes stop

Examples

#include 

void setup(){
 Robot.begin();
 Robot.beginSpeaker();//Initialize the sound module
}

void loop(){
 char aTinyMelody[] = "8eF-FFga4b.a.g.F.8beee-d2e.1-";// This is what we will play
 Robot.playMelody(aTinyMelody);// Play the melody
}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc