AI智能
改变未来

arduino btn

boolean pushButton;void setup() {// put your setup code here, to run once:pinMode(2,INPUT_PULLUP);pinMode(13,OUTPUT);}void loop() {// put your main code here, to run repeatedly:pushButton = digitalRead(2);if (pushButton) {   //if pushButton==1,btn is not pusheddigitalWrite(13,HIGH);} else {digitalWrite(13,LOW);}}

按钮按下灯灭,不按灯亮

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » arduino btn