Example for Arduino-315MHz RF Receiving

This article offers a practical guide to using the Arduino 315MHz RF Receiving module, focusing on the RF Shield with SC2272. It explains address coding, oscillation frequency matching, and provides step-by-step instructions for setting up the system, ensuring reliable communication between devices.

Operation Steps

  1. According to the address code of the remote wireless telecontroller, set the address code of this shield by pluging or pulling the jumper.Only when the address code of the telecontroller is equal to the address code of the shield, the command transmit by the telecontroller can be received by this shield. The address code of our remote wireless keynob 315MHz(SKU:FIT0355) is floating, so you must remove all the jumpers.(8 jumpers all)

  2. Turn the switch to PROG,upload the sample code to your Arduino. When done, turn the switch to RUN.

  3. Adjust the position of the antenna, which makes it perpendicular to the board. This can increase the receiving distance.

  4. Open the serial monitor, press the button on the telecontroller. You can see the LED will twinkle once when you press the button. This indicates that this shield has received command from the telecontroller. You can also see which button pressed on the serial monitor. The high level 1 is the pressed button.

Sample Code

    /*The following 4 pin definitions,correspond to 4 buttons on the remote control(The telecontroller is Remote Wireless Keynob 315MHz(SKU:FIT0355))*/
    int D1 = 8;    //The digital output pin 1 of decoder chip(SC2272)
    int D2 = 9;    //The digital output pin 2 of decoder chip(SC2272)
    int D3 = 10;   //The digital output pin 3 of decoder chip(SC2272)
    int D4 = 11;   //The digital output pin 4 of decoder chip(SC2272)
    int ledPin = 13;   //Receiving indicator

    volatile int state = LOW;

    void setup()
    {
      Serial.begin(9600);
      /*The four pins order below correspond to the 4 buttons on the remote control.*/
      pinMode(D4, INPUT);  //Initialized to input pin, in order to read the level of the output pins from the decoding chip
      pinMode(D2, INPUT);
      pinMode(D1, INPUT);
      pinMode(D3, INPUT);
      pinMode(ledPin, OUTPUT);
      attachInterrupt(1,blink,RISING); //Digital pin 3,interrupt 1,corresponds to receiving interrupt pin of the decoding chip
      digitalWrite(ledPin, LOW);
    }

    void loop()
    {
      if(state!=LOW)
         {
           state=LOW;
           delay(1);   //delay some time,wait for stable level on the output pin
           digitalWrite(ledPin, HIGH);
           Serial.print(digitalRead(D4));  //Read individually output pins of the decoder chip,and put them on the serial monitor
           Serial.print(digitalRead(D2));
           Serial.print(digitalRead(D1));
           Serial.println(digitalRead(D3));
           delay(300);
           digitalWrite(ledPin, LOW);
         }
    }

    void blink()
    {
     state =! state;
    }

Was this article helpful?

TOP