範例使用到的音階有Do(523Hz), Re (587Hz), Mi(659Hz), Fa(698Hz), So(784Hz), La(880Hz), Si(988Hz) 到高音 Do (1047Hz)
//兩隻老虎
int buzzer=3; //設定蜂鳴器接腳為第3孔
int duration = 500;
int aSo = 392;
int bDo = 523;
int bRe = 587;
int bMi = 659;
int bFa = 698;
int bSo = 784;
int bLa = 880;
int bSi = 988;
int bDDo = 1047;
void setup()
{
pinMode(buzzer,OUTPUT); //設定蜂鳴器為輸出
}
void loop()
{
tone(3,bDo,duration);
delay(600);
tone(3,bRe,duration);
delay(600);
tone(3,bMi,duration);
delay(600);
tone(3,bDo,duration);
delay(800);
tone(3,bDo,duration);
delay(600);
tone(3,bRe,duration);
delay(600);
tone(3,bMi,duration);
delay(600);
tone(3,bDo,duration);
delay(800);
tone(3,bMi,duration);
delay(600);
tone(3,bFa,duration);
delay(600);
tone(3,bSo,duration);
delay(800);
tone(3,bMi,duration);
delay(600);
tone(3,bFa,duration);
delay(600);
tone(3,bSo,duration);
delay(800);
tone(3,bSo,duration);
delay(600);
tone(3,bLa,duration);
delay(600);
tone(3,bSo,duration);
delay(600);
tone(3,bFa,duration);
delay(600);
tone(3,bMi,duration);
delay(700);
tone(3,bDo,duration);
delay(800);
tone(3,bSo,duration);
delay(600);
tone(3,bLa,duration);
delay(600);
tone(3,bSo,duration);
delay(600);
tone(3,bFa,duration);
delay(600);
tone(3,bMi,duration);
delay(700);
tone(3,bDo,duration);
delay(800);
tone(3,bDo,duration);
delay(700);
tone(3,aSo,duration);
delay(700);
tone(3,bDo,duration);
delay(800);
tone(3,bDo,duration);
delay(700);
tone(3,aSo,duration);
delay(700);
tone(3,bDo,duration);
delay(800);
delay(2000);
}