How to use a 315MHz RF Remote with an Arduino
We already did a tutorial on how to use an IR remote control, today we will learn how to use an RF remote.
Since the RF signals can go through walls, this kind of remote can be useful when your project is in another room.
The remote has 4 buttons which corresponds to 4 pins on the receiver. The RF module uses the SC2272-M4, which is the momentary version, so the pin will stay HIGH as long as we hold down the button.
We will use a 4bits 7 segment LED display to show which button was pressed instead of the serial monitor.
Both the Display and the RF receiver need 5V and Ground.
We are connecting the 5V – GND of the Arduino to the breadboard power rails so we can connect both modules.
The RF receiver has 4 pins for each buttons, and one DT (trigger) pin that will activate if any buttons is pressed.
The Display uses the I2C bus, so it only needs 2 pins.
We are using the TM1637 library to drive the 7 segment display.
Instead of IF statements to detect which button is pressed, we will use WHILE loops in our code instead.
This way our code will pause and wait for us to press a button, instead of looping and having to refresh the 7 segment display over and over again.
The first WHILE loop will check all the receiver pins, if ALL of them are LOW, the code will stay in the loop, if any button is pressed, then that pin will become HIGH making the condition false and the code will exit the loop.
The other WHILE loops check which pin is HIGH and execute the code inside.
As always, you can have a look at the tutorial video for more information.
Copy and paste the above code in the Arduino IDE to program your Arduino.
Download the TM1637 created by avishorp here: https://github.com/avishorp/TM1637
Once downloaded, just extract the content of the zip files inside your “arduino/libraries” folder.