* 音的表示方法是 1 2 3 4 5 6 7
* 音的名称(也就是音名) C D E F G A B
* 音的唱名(也就是唱法) DO RE MI FA SOL LA SI
*
* note frequency period timeHigh
* c 261 Hz 3830 1915
* d 294 Hz 3400 1700
* e 329 Hz 3038 1519
* f 349 Hz 2864 1432
* g 392 Hz 2550 1275
* a 440 Hz 2272 1136
* b 493 Hz 2028 1014
* C 523 Hz 1912 956
Edison 采用arduino的编译器进行下载
代码如下:
/* Melody
* (cleft) 2005 D. Cuartielles for K3
*
* This example uses a piezo speaker to play melodies. It sends
* a square wave of the appropriate frequency to the piezo, generating
* the corresponding tone.
*
* The calculation of the tones is made following the mathematical
* operation:
*
* timeHigh = period / 2 = 1 / (2 * toneFrequency)
*
* where the different tones are described as in the table:
*
* 音的表示方法是 1 2 3 4 5 6 7
* 音的名称(也就是音名) C D E F G A B
* 音的唱名(也就是唱法) DO RE MI FA SOL LA SI
*
* note frequency period timeHigh
* c 261 Hz 3830 1915
* d 294 Hz 3400 1700
* e 329 Hz 3038 1519
* f 349 Hz 2864 1432
* g 392 Hz 2550 1275
* a 440 Hz 2272 1136
* b 493 Hz 2028 1014
* C 523 Hz 1912 956
*
* http://www.arduino.cc/en/Tutorial/Melody
*/
int speakerPin = 2; // Grove Buzzer connect to D3
int length = 15; // the number of notes // 音调的数目
char notes[] = "ccggaagffeeddc "; // a space represents a rest // 字符最后的空格代表乐曲间的休息