int buzz= 13;
int low[]= {0, 1908, 1701, 1515, 1433, 1276, 1136, 1012};
int middle[]= {0, }
int high[]= {0, }
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(buzz, OUTPUT);
}
void play(int tone, unsigned long howlong){
unsigned long time= millis();
while(millis() – time < howlong){
digitalWrite(buzz, HIGH);
delayMicroseconds(low[tone]);
digitalWrite(buzz, LOW);
delayMicroseconds(low[tone]);
}
delay(10);
};
void play_little_apple(){
play(1, 250);
play(1, 250);
play(5, 250);
play(5, 250);
play(6, 250);
play(6, 250);
play(5, 250);
play(4, 250);
play(4, 250);
play(3, 250);
play(3, 250);
play(2, 250);
play(2, 250);
play(1, 250);
}
void loop() {
// put your main code here, to run repeatedly:
play_little_apple();
}
excel 算音階對應到的頻率
=ROUND(1/E2/2*1000000,0)