ESP32 Starter Kit
(continued from previous page)
void loop() {
if (irrecv.decode(&results)) {
ir_rec = results.value; //assign the signal to the variable ir_rec
if (ir_rec != 0) { //Prevente the code from repeating execute when the␣
˓→button is pressed
if (ir_rec == 0xFF02FD) { //Determine whether the received IR signal is from␣
˓→button OK
led_val = !led_val; //Reverse a variable. If the initial value is 0, it␣
˓→turns to 1 after reversing
digitalWrite(led, led_val);
}
}
irrecv.resume(); //Release the IR remote and receive the next value.
}
}
8.5.31 Project 30: Smart Home
1. Description
In this technology era, we are all familiar with smart home. It is a system that can control electric appliance via buttons.
In this project, we seek to stimulate a smart home via an IR remote control. With Arduino MCU as its core, it can be
used to control light, air conditioners, TV and security monitors.
8.5. Arduino Project 157