const int BUTTON = 8;
const int LED = 13;
int value;
void setup()
{
// put your setup code here, to run once:
pinMode(BUTTON, INPUT);
pinMode(LED, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
value = digitalRead(BUTTON); // 讀取傾斜開關(guān)
if(value){
digitalWrite(LED, LOW);// 開關(guān)傾斜,LED小燈點(diǎn)亮
}else{
digitalWrite(LED, HIGH);// 開關(guān)直立,LED小燈熄滅
}
delay(100);
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/) | Powered by Discuz! X3.1 |