Project - IR Sender
In the previous project, we learned how to capture signals from a remote controller. In this project, we’ll build our own remote controller to replicate the functionality of an existing one.
First, choose a button from an existing remote that you’d like to duplicate, and check the Protocol, Address, and Command information from the serial monitor in the previous project.
Now, let’s write the code to replicate it!
The right leg of the IR908-7C is connected to GPIO 4 on the Lonely Binary UNO R3. The left leg is connected to a 220Ω resistor, which is then connected to Ground.
The button is connected to GPIO 3 on the Lonely Binary UNO R3, with the other end connected to 5V. This means that when the button is pressed, GPIO 3 will be in a HIGH state. To ensure that GPIO 3 defaults to a LOW state when the button is not pressed, we use a pull-down resistor of 10kΩ connected to Ground.
Sets the button pin (pin 3) as an input.
The IR sender is initialized on pin 4.
The code constantly checks if the button connected to pin 3 is pressed (digitalRead(BTN_PIN) == HIGH).
The IrSender.sendSamsung() function sends the IR signal with the defined address, command, and repeats using the Samsung protocol.
Don't forget to add button debounce delay before the if end.