// define the pin numbers names
int inputPin = 2;
int ledPin = 13;
void setup() {
// declare inputPin to be an input
pinMode(inputPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (digitalRead(inputPin) == HIGH) {
digitalWrite(ledPin, HIGH);//滾珠開關ON,led燈亮
}
else{digitalWrite(ledPin, LOW);}
}
沒有留言:
張貼留言