验证中...
Languages: Arduino
Categories: 其他
Latest update 2019-11-08 18:11
1.完成使用继电器控制直流电机功能。 2.通过按键控制继电器,实现按键控制直流电机功能。
Raw Copy
volatile int incomedate;
volatile int click;
volatile boolean b1;
volatile boolean b2;
void setup(){
incomedate = 0;
click = 0;
b1 = false;
b2 = false;
pinMode(6, INPUT);
pinMode(10, OUTPUT);
Serial.begin(9600);
}
void loop(){
pinMode(6, INPUT_PULLUP);
b1 = !digitalRead(6);
if (b1 != b2) {
click = 1 - click;
if (click == 1) {
digitalWrite(10,HIGH);
} else if (click == 0) {
digitalWrite(10,LOW);
}
while (digitalRead(6) == 0) {
}
b1 = false;
b2 = false;
delay(200);
}
analogWrite(3,0);
if (Serial.available() > 0) {
incomedate = Serial.read();
if (incomedate == 'H') {
digitalWrite(10,HIGH);
} else if (incomedate == 'L') {
digitalWrite(10,LOW);
}
}
}
继电器控制LED灯.png
继电器控制开关及风扇.png
继电器停.jpg
继电器转.jpg

Comment list( 0 )

Sign in for post a comment

Help Search