2020年11月23日 星期一

喵~Aurduino+makeruno初體驗

音符(蜂鳴器發出聲音)

  • 音樂音符頻率對照表
  • 小星星
    • #define C 523///定義音符頻率
    • #define D 587
    • #define E 659
    • #define F 698
    • #define G 784
    • #define A 880
    • int music[]={C,C,G,G,A,A,G,0,F,F,E,E,D,D,C,0,G,G,F,F,E,E,D,0,G,G,F,F,E,E,D,0,C,C,G,G,A,A,G,0,F,F,E,E,D,D,C};///0是不播音
    • void setup() {
    •   // put your setup code here, to run once:
    •   delay(1000);
    •   pinMode(8,OUTPUT);
    •   for(int i=0;i<sizeof(music)/sizeof(int);i++){
    •     tone(8,music[i],100);///播放(Pin8是蜂鳴器)
    •     delay(250);///音之間的間隔
    •   }
    • }
    • void loop() {}
  • 參考網站(官方範例)
    • https://github.com/CytronTechnologies/MakerUno_Examples

沒有留言:

張貼留言