Exercise 24 - Using radio frequency controller

1.      INTRODUCTION

Radio frequency is an electromagnetic waves, which are between 3KHZ and 300GHZ range. To receive the signal, it is necessary to use an antenna. However, multiple signals are sent to the same antenna at the same time. To receive the correct signal it is necessary to use a tune into a particular frequency.


It is necessary to have one transmitter and one receiver to communicate both by radio frequency.


2.      HOW TO CONNECT?

We are going to use YK04 radio frequency module, it can be use without connect it to Arduino but to test it in Serial monitor we are going to connect it to digital pins (7…11). Don’t forget to connect also to 5V and GND

EXERCISE_A



Materials:

·         Arduino UNO board

·         Some wire Jumpers

·         Wireless transmitter and receiver


3.      PROGRAMMING

This program, test yk04 RF module. You can view how radio-frequency communication actuates.

//Firt, Declare pin.

int valid = 7;//This pins is activated when it receive valid signal

int A = 8;

int B = 9;

int C = 10;

int D = 11;

void setup()

{ Serial.begin (9600);

  pinMode (13, OUTPUT) ;

  pinMode (12, OUTPUT) ;

  for (int i = 7 ; i < 12 ; i++) //You can save lines setting as INPUT

    pinMode(i, INPUT) ;          //consecutive pins with for loop

}

 

When the receiver detects a signal, it evaluates if the signal is valid. Whether the signal is valid, pin7 is set to a HIGH state and then, receiver identifies the signal of the button pressed to activate the corresponding pin.

 

void loop()

{

  if (digitalRead(valid) )     //If it receive valid signal

  { Serial.print("Valid trans. \t");

 

    if (digitalRead(A)) {

      Serial.print( "Button A, pressed");

      delay (500) ;

    }

 

    if (digitalRead(B)) {

      Serial.print( "Button B, pressed");

      delay (500) ;

    }

 

    if (digitalRead(C))

    {

      Serial.print( "Button C, pressed");

      delay (500) ;

    }

 

    if (digitalRead(D))

    {

      Serial.print( "Button D, pressed");

      delay (500) ;

    }

 

    Serial.println("\t");

  }

 

}


Última modificación: Tuesday, 21 de January de 2020, 10:30