2019年11月28日 星期四

week12 -yusyuan🌓

week 12互動技術

2019_11_28

------------------------------------------------------------------------
🔺 MakerUNO
  • 先到老師的公開雲端下載驅動程式
  • 照著老師的步驟\作

按了有聲音(Do)


int Do=523;
int Re=587;
int Mi=659;


void setup() {
  // put your setup code here, to run once:
  pinMode(8,OUTPUT);
  digitalWrite(2,INPUT_PULLUP);

}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(2)==LOW)tone(8,Do,1000);
  else noTone(8);

}


按了有聲音(會有小蜜蜂so mi mi fa re re.......)


int Do=523;
int Re=587;
int Mi=659;
int Fa=689;
int So=784;
int song[13]={So,Mi,Mi,Fa,Re,Re,Do,Re,Mi,Fa,So,So,So};
int now=0;
bool UP=true;
void setup() {
  // put your setup code here, to run once:
  pinMode(8,OUTPUT);
  digitalWrite(2,INPUT_PULLUP);

}
void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(2)==LOW){
    tone(8,song[now],200);
    UP=false;
    now =(now+1)%13; ///避免陣列song[now] 超過而當掉
  }
  else    UP=true;
 
   delay(300);
}

沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

回顧這學期的作品:  期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...