IR remote arduino

Remote control system with IR and arduino

We are going to create an IR remote system with arduino which will open and close a door through a servomotor SG90

Purpose of this article is to know how exactly the infrared radiation works and how can we use it with the help of Arduino.

Please make sure that you will check out other constructions and videos that we have on page tutorials.

What is infrared radiation

Infrared radiation has wave lengths between 700nm και 106nm are about 60% of the solar radiation.

Penetration to the human skin is very low, reaching up to 1mm (max). Some of the properties that infrared radiation has are:

  • They can selectably absorbed from some materials and increase temperature.
  • They penetrate Fog and clouds.
  • No chemical reactions and glow.

You can see at the following image the spectrum range where the infrared radiation works. It is right after the visible spectrum that we can see with bare eyes.


The project

By using an IR remote system and the help of arduino, we will use a remote control to open and close a “garage door”.

There will be a door which will open with the help of the servomotor in order to get in or out. The main point that we are trying to make with this project is not to teach you how to make a garage door automation. For that we would require other equipment.

Servo SG90 preperation

When we work with servos, we adjust the degrees. Because of that we must have a reference point, we need to adjust properly our 0 degrees

Servo sg90

We connect the servo and within Setup() function we rotate at 0 degrees

Materials we are going to need for IR remote:

  • 1 x arduino (any edition)
  • 1 x infrared remote control transmiter + receiver
  • Some jumper wires
  • bredboard
  • 1 x Servomotor SG90

Pressing to up arrow from the IR remote control, door opens and remains open for 15sec, unless we press the arrow down button to close it sooner.

IR Remote module για Arduino

You will need the library in order to get things working.
Download the same as i did in the video.

Download the same as i did in the video.

Με κόστος λιγότερο από 1,5€, πήρα έναν πομπό (τηλεχειριστήριο) και έναν δέκτη. Χρειάστηκε μία μπαταρία CR2032 3.0v την οποία μπορείτε να πάρετε από οπουδήποτε πουλάνε ηλεκτρολογικό υλικό (παίζει να την βρείτε και στα περίπτερα)

Arduino IR remote control
Lithium battery CR2032

The circuit

IR remote Arduino

Code

// Libraries
include <Servo.h>
include <boarddefs.h>
include <IRremote.h>
include <IRremoteInt.h>
include <ir_Lego_P
// Variables
int servoPin = 7;
const int infraredPin = 6;
int closePosition = 10;
int openPosition = 180;
long previousMillis = 0;
long interval = 8000;
IRrecv irReceiver(infraredPin);
decode_results results;
Servo myservo;
void setup() {
myservo.attach(servoPin);
Serial.begin(9600);
//myservo.write(pos);
//Activate IR.
irReceiver.enableIRIn();
myservo.write(closePosition);
}
void loop() {
unsigned long currentMillis = millis();
if (irReceiver.decode(&results))
{
Serial.println(results.value, HEX);
irReceiver.resume();
switch(results.value)
{
case 0xFF18E7:
myservo.write(openPosition);
break;
case 0xFF4AB5:
myservo.write(closePosition);
previousMillis = currentMillis;
break;
}
}
if (currentMillis - previousMillis > interval)
{
previousMillis = currentMillis;
myservo.write(closePosition);
}
}

Video

November 7, 2019

0 responses on "IR remote arduino"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Σχεδιασμός © GetCert. Με επιφύλαξη παντός δικαιώματος.