2018年12月6日 星期四

Week13 _沈哲民

安裝驅動程式(驅動maker uno)





注意

1. Maker uno 的模式
2.  連接com7 !




processing 和 arduino 互動

打開processing ---> 文件 ------> 範例程序 -------> Serial ------> SimpleRead



製到Arduino
將腳位改成pin2

**程式碼:
int switchPin = 4;                       // Switch connected to pin 4

void setup() {
  pinMode(switchPin, INPUT);             // Set pin 0 as an input
  Serial.begin(9600);                    // Start serial communication at 9600 bps
}

void loop() {
  if (digitalRead(switchPin) == 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




記住 processing 要改成com7



沒有留言:

張貼留言