Remote control with Arduiono

remote control for arduino

In this practice we are going to use the Wireless Remote control IC 2262/2272 4 CH (4 315 channels) Mhz for arduino and, we are going it to start up from zero.

1 This device, to make it work, first is necessary to buy it (jejejeje). Good, the last one that I bought cost 1.70 ‚¬ in aliexpress, so it does not have to differ today much from that amount.

2 That is. this pack is made up of an emitter that emits 4 signals codified to a frequency of 315 Mhz, with possibility of putting receiving antenna in the receiving module, which ample the work rank.

This pair of component (Emitting-receiving) uses the C.I PT2262/PT2272 that carry out a basic wireless remote control. They are used normally in economic systems because they use fixed codes and they do not issue the encriptada information.

Commonly they are used in controls of garages (doors), control of ventilators, simple alarms, toys, etc.

They are not advisable when the security is important.

In order to make this practice we needed:

  • Arduino Uno
  • Cables of connection (fiber-male)
  • kit of radio controls mentioned before
  • Diodes leds with protection resistance

A little but this device

The radio control emits the frequency codified with 4 channels available. This makes possible to have control on 4 variables. If it were the control of a car, a channel can be to put it in march, the other to invest turn of the motor, other to move the wheels and 4 channel for some siren.

We happen to explain the program

Xd-YK04

In the detail of the receiver, we have Masa (GND) and the feeding of 5 volts (Vccc). Then, we obtain a called exit Vt that offers an exit to us when one of the channels has been received and, finally, D1, D2, D3 and D4 is the exits of the channels, that generate a signal (High) when receiving the signal of radio corresponding to their channel.

Another point marked in the module is the corresponding one to the Antenna, that will not be necessary for short distances but it is very useful if we are going to operate beyond the 10 meters.

The Screw marked with red dye is a fit variable condenser and, therefore, it is not due to touch under any concept

As those terminals are going to be exits of the receiver, we must it enter arduino by the corresponding ports. We can choose that ports we can use to receive these signals and is necessary to form them as entrance ports.

Something important in this work is that we are not going to need any bookstore.

In our case we are going to use in future from port 7

Program:

void setup () - > Configuramos the program
   \ {Serial.begin (9600); - > Establecemos the speed of the port series
      pinMode (13, OUTPUT); - > port 13 exit
      pinMode (12, OUTPUT); - > Puerto 12 exit
      for (int i = 7; i < 12; i++) - > *rutina to put the pins to entrance
           pinMode (i, INPUT);
   }

* In this case, the explanation of this routine is the following one. The first part assigns value to him i to 7 and says that whenever is smaller of 12 must it increase in one

In 2 part puts pinMode i, so that the first i is 7, and it puts it as input, soon it raises the line of above, is increased the i to 8, low to the following line and puts pin 8 to input. Thus until the 12

This would be equivalent to say

pinMode (7, INPUT);
pinMode (8, INPUT);
 pinMode (9, INPUT);
 pinMode (10, INPUT);
pinMode (11, INPUT);
pinMode (12, INPUT);

Another new instruction is the Serial.begin, that activates the out port to us to be able to visualize data

2 part:

void loop () - > Empieza the bow
   \ {   
      if (digitalRead (7))     //If there is signal of valid radio
         \ {Serial.print (arrives a value to Us. \ t€); //is printed arrives a value to Us 
            if (digitalRead (8))  //we read port 8 to see if signal arrives
                Serial.print (Button A has been pressed€); //is printed, has been pressed
            if (digitalRead (9)) //becomes the same with the 9
                Serial.print (Button B has been pressed€);
            if (digitalRead (10)) //we repeated for the 10
              \ { 
                   Serial.print (Now Button C has been pressed.€);
                   digitalWrite (12! digitalRead (12)) ; //We removed by port 12 the value from 12
                   delay (500); //we waited for 0,5 seconds
               }
            if (digitalRead (11))
               \ { 
                   Serial.print (button D has been pressed€);
                   digitalWrite (13! digitalRead (13)) ; //activates exit 13
                   delay (500); //is expected 0.5 seconds
               }
            Serial.println (\ t€); //Prints a tabulator
         } 
   }

3 Part.

How to include the suitable instructions so that, when beating a button, the motor changes of state.

If we have beaten so that it raises but, we want to stop it before time, for example in the middle of way, without having to hope to that it stops by the aim of race of the motor, we must include a code so that the entrance is read and, yes before had been beaten, it is stopped, and on the contrary, it is put to work

Before following with the project and, with the idea to incorporate this function, I advise that this program mounts or, is simulated with tinkercad.com

int ledPin = 13; //We connected LED 13 and we assigned to variable ledPin int inPin = 7; //the reading button is the 7. We called inPin int val = 0; //we created val variable that will read state motor pin 7 int = 0; /variable intern who comes to tell us how void is the motor setup () \ {pinMode (ledPin, OUTPUT); //we put ledPin as exit pinMode (inPin, INPUT); //inPin as entrance} void loop () \ {val = digitalRead (inPin); //the val value takes the reading from pin 7
  if (val ==HIGH && motor ==LOW)/* In the previous line, if a 1 has arrived (it has been pressed) and the motor is stopped, then we put the motor to work * 
 \ {motor = 1; //puts motor variable to 1 digitalWrite (ledPin, HIGH); //activates motor
 
 delay (1000); /delay of the second //sets the LED to the val button's VALUE} = digitalRead (inPin); //we return to read the value if (val motor ==HIGH && == 1)/* just like before, but the motor was ignited, we must extinguish it to +/\ {motor = 0; //puts motor variable to zero digitalWrite (ledPin, LOW); //deactivates motor
  delay (1000);
 
 }

We already are close. It is only necessary to construct to the program (not it under so that it is constructed above with the given code.

Activity:

Part 1. To mount the program that is indicated above and to verify its operation.

Part 2:  To mount a program so that it activates a remote traffic light, so that three channels for each one of the lights are used and a fourth channel is reserved to close a fence from access to the garage.

The idea is to be able at a distance to control the access to a garage by a worker.

The lights, to being of power, need a system relays. If it is not had the same, to use diodes leds.

For the barrier (motor), it is possible to be used a siren or another device.

Part 3. To make a codified system, that using the entrance of the four channels, activates a system of:

  1.  Arduino begins to read the information given by the transmitter when it detects the Vt entrance, and generates a temporary space of 10 seconds to make a decision.
  2. If after the 10 seconds the sequence that has entered by the channels is correct, a light ignites (also the opening of a lock can be activated)
  3. If to the 10 seconds, the code is erroneous, goes off an alarm
  4. The code is made up of the sequence of 8 entrances of the received channels, corresponding to channels ABCDDCBA.

Dom³tico project to control awning

With the project of the RF control, we are going to carry out a final work where one controls the ascent and slope of an awning, according to atmospheric conditions (sun, rain and seeing), along with the control manual of the control and adding a IOT control (Internet of Things). For this last part, we must consider all the work that comes in the connection Control from LED with ESP8266