|
遥控+继电器
Jan 5, 2021 2:15:02 GMT
Post by 邱老师 on Jan 5, 2021 2:15:02 GMT
继电器再接一个LDE,用红外线遥控控制继电器,来开关LED. 红外需要安装库 接线:继电器左侧标注:RL1和RL2都可以,接到uno上D13口 D11口接到红外接收插座 链接:https://pan.baidu.com/s/1uIhmIiX8cS257GcxAXE5MQ 提取码:zc6l #include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value);
irrecv.resume(); // Receive t
{ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); }
digitalWrite(LED_BUILTIN,LOW);
}
}
|
|