2018年12月6日 星期四

WEEK 13 jn

WEEK13 互動技術概論

首先先去processing找範例程式
接著再複製最下方的程式碼到arduino
並且改一些程式碼 
int switchPin = 4;                       // Switch connected to pin 4

void setup() {  ///改成2.因為MakerUNO的按鈕在PIN 2
  pinMode(switchPin, INPUT); // Set pin 0 as an input
  pinMode(2,INPUT_PULLUP);
  Serial.begin(9600);                    // Start serial communication at 9600 bps
}

void loop() {
  if (digitalRead(2) == HIGH) {  // If switch is ON,
    Serial.write(1);               // send 1 to Processing
  } else {                               // If the switch is not ON,
    Serial.write(0);               // send 0 to Processing
  }
  delay(100);                            // Wait 100 milliseconds
}

沒有留言:

張貼留言