We use infrared transmitters when making Cubecon. So we studied how to send infrared values to an infrared transmitter. We also studied an infrared receiver to make sure it works properly.
Required Library- IRremote
First, we tested the remote control to verify that the infrared receiver works normally. Depending on the infrared value of the remote control button, the color of the RGB LED has changed, which is normally operated.
Infrared TransmitThen we studied an important infrared transmitter in Cubecon. The schematic is very simple.
Infrared values of the remote control buttons were sent to the infrared transmitter and the infrared receiver received the value.
Also, we changed RGB LED colors to correspond to infrared value.
Code Explanation- Infrared Receive
# include <IRremote.h>
This is the library required to receive infrared value.
int RECV_PIN = 3;
The port on which the output of the infrared receiver is connected, allowing users to connect arbitrarily.
IRrecv irrecv(RECV_PIN);
IRrecv
is a class name for using infrared control. You can use the defined classes to receive the infrared remote control.
decode_results results;
This class is responsible for processing the decoding results of the remote control receive data; you can address the protocol type, decoding data, protocol type, number of bits, raw data, raw data length, etc.
irrecv.enableIRIn();
It is a function to start input of infrared remote control. You can use it in the setup()
function.
irrecv.decode(&results)
Decode incoming remote data.
irrecv.resume();
After the decoding is finished, the setting for receiving the input again is initialized.
- Infrared Transmit
Types of infrared transmission are: NEC, SONY, RC5, RC6. Most of use NEC type.
irsend.sendNEC(12495, 16);
Write the type of infrared behind the send. In the ( ), write the infrared value and the number of bits. It is recommended to use infrared value in hex code.
(Example / 12495 ㅡ> 0xFF18E7 )
Reference site
Comments
Please log in or sign up to comment.