
注意
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

 
沒有留言:
張貼留言