1.1. Arduino 的 Output (LED, Motor, Servo)
1.2. Arduino 的 Input (Button PULL_UP, 可變電阻, 光敏電阻)
1.3. Arduino 的 Serial COM (communication) 與電腦連接通訊
void setup(){
//start serial connection
Serial.begin(9600);
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(13, OUTPUT);
int now=0;
}
void loop(){
//read the pushbutton value into a variable
int sensorVal = digitalRead(2);
if (sensorVal == HIGH) {
digitalWrite(13, LOW);
}
else {
digitalWrite(13, HIGH);
Serial.write(65);
delay(120);
}
}




沒有留言:
張貼留言