Safari browser sometimes has issues displaying images...

I.e: *you have to click on the images to see them...

For a better browsing experience on Brainy-Bits

Please use Chrome, Edge or Firefox browser.

  • Brainy-Bits

Using a 315MHz RF Remote with an Arduino



OVERVIEW


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.

PARTS USED

4 Digits 7 Segment Display

Amazon usa

Amazon canada


315MHZ Wireless remote with Receiver

Amazon usa

Amazon canada


Arduino UNO

Amazon usa

Amazon canada


These are Amazon affiliate links...

They don't cost you anything and it helps me keep the lights on

if you buy something on Amazon. Thank you!

CONNECTIONS




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.


THE CODE


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.


#include "TM1637Display.h"  //  Library for 7 segment Display

//{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
//0~9,A,b,C,d,E,F  // Available for display
 

#define CLK 3  // Pins for display     
#define DIO 4
TM1637Display tm1637(CLK,DIO);
 

void setup(){
  tm1637.init();  // Reset Display 
  tm1637.set(BRIGHT_TYPICAL); 
  //BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
  delay(1500);  // Delay to let system boot 
}

 
void loop(){
 

  while (digitalRead(9) == LOW && digitalRead(10) == LOW && digitalRead(11) == LOW && digitalRead(12) == LOW) {
    tm1637.display(3,0);  // Loops until button is pressed
  }  
  
  tm1637.clearDisplay();  // Clear display
  
  while (digitalRead(9) == HIGH) {  // Button 1 pressed
    tm1637.display(0,1);
  }
  
  while (digitalRead(10) == HIGH) {  // Button 2 pressed
    tm1637.display(1,2);
  }  
  
  while (digitalRead(11) == HIGH) {  // Button 3 pressed
    tm1637.display(2,3);
  }
  
  while (digitalRead(12) == HIGH) {  // Button 4 pressed
    tm1637.display(3,4);
  }
    tm1637.clearDisplay();

}


TUTORIAL VIDEO




DOWNLOAD


Copy and paste the above code in the Arduino IDE to program your Arduino.


Used Libraries:

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.

36 views

All my content is and will always be Free.

If you feel that my Videos / Tutorials are helping, and you would like to contribute...

 You can toss some coins in the Tip Jar via PayPal.

Select amount then click the “Donate” button.

©2020 by Brainy-Bits