2019年11月28日 星期四

week11

#define NOTE_C5 523
#define NOTE_D5 587
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_G5 784

void setup() {
  // put your setup code here, to run once:
  pinMode(8,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()){
      char now = Serial.read();
      if(now=='1') tone(8,NOTE_C5,300);
      if(now=='2') tone(8,NOTE_D5,300);
      if(now=='3') tone(8,NOTE_E5,300);
      if(now=='4') tone(8,NOTE_F5,300);
      if(now=='5') tone(8,NOTE_G5,300);
    }
}


import processing.serial.*;
Serial myPort;

void setup(){
  myPort = new Serial(this, "COM3",9600);
}
void draw(){

}
void keypressed(){
  if(key=='1') myPort.write('1');
  if(key=='2') myPort.write('2');
  if(key=='3') myPort.write('3');
  if(key=='4') myPort.write('4');
  if(key=='5') myPort.write('5');
}

沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

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