验证中...
Mixly继电器控制直流电机
Raw Copy
volatile boolean b1;
volatile boolean b2;
volatile int click;
volatile int laststate;
void setup(){
pinMode(12, INPUT);
pinMode(3, OUTPUT);
b1 = 0;
b2 = 0;
laststate = 0;
click = 0;
pinMode(12, INPUT_PULLUP);
}
void loop(){
b1 = digitalRead(12);
if (b1 != digitalRead(12)) {
delay(1000);
b2 = digitalRead(12);
}
if (b2 == b1) {
laststate = b1;
digitalWrite(3,HIGH);
click = click + 1;
}
if (click == 2) {
digitalWrite(3,LOW);
click = 0;
}
}

Comment list( 0 )

Sign in for post a comment

Help Search

191139_cd20d5fd_5186603 191143_ebef6f8d_5186603