Experiment 20: infrared remote control: 1、Infrared receiving head introduction

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

Experiment 20: infrared remote control

Note: the IRremote folder into the compiler to install the directory under the Arduinolibraries.

For example:C:\Program Files\Arduino\libraries

1、Infrared receiving head introduction

一、What is the infrared receiver head?


From the infrared remote control signal is a series of binary pulse
code. In order to make it from other infrared signal interference in
wireless transmission process, usually first its modulation on the
specific carrier frequency, and then by the infrared emitting diodes
emitted, and the infrared receiving device to filtering the clutter,
they receive the specific frequency signal and restore it to the binary
pulse code, also is demodulation.
二、Working principle
The built-in receiver will transmit the infrared emission tube light
signal into a weak signal, this signal through the IC internal amplifier
amplification, and then through the automatic gain control, band-pass
filtering, demodulation, waveform shaping after the original encoding to
restore the original signal output by the receiver signal output pin
input to the electrical appliances on the encoding recognition circuit.

三、Pin and connection of infrared receiving head

The infrared receiving


head has three pins as
follows:
When using the VOUT to the
analog port, GND received
the experimental board GND,
+5v. received the VCC on the
experimental board
Infrared remote
control experiment

1, experimental
device

As for the infrared remote control: 1

Of the infrared receiving head: 1


The LED of light: 6

The 220 resistor: 6

The colorful line: some of the bread


2、Experimental connection
First, the board is connected; then the infrared receiver head in
accordance with the above method, the VOUT connected to the digital 11
pin, the LED lamp through the resistor connected to the digital pin
2,3,4,5,6,7. back to complete the circuit part of the connection.

3、Experimental principle
To decode a remote controller must be aware of the remote control of the
encoding way. This product is used to control the code of the way: NEC
agreement. Following the introduction of the NEC protocol:
·NEC protocol description: features: (1) 8 address bits, 8 bit command

(two) for the 2 time in order to address the reliability address bit and
the command bit

(3) pulse position modulation

(4) carrier frequency 38kHz

(5) each time for the 1.125ms ring 2.25ms


·Logic 0 and 1 are defined as follows.:

·Press the launch pulse at once:


The image above shows a typical pulse sequence of NEC. Note: this first
send LSB (the most low) protocol. In the above pulse transmission of the
address for the 0x59 command 0x16. a message is from a high level of
9ms, then there is a low level of 4.5ms, and the command code. The
address and command code. Second times all bits are taken back, can be
used for the confirmation of the message. Because every point and it
takes anti length repeat, you can ignore the if you are not interested.
Take the counter, you can also expand the address and command, to every
16!
Key press a period of time before the release of the launch pulse:

A command sent once, even on the remote control button is still pressed.
When the button has been pressed, the first 110ms of the pulse and the
image above, after each 110ms repeat code transmission.
·repetitive pulse

Note: pulse waveform of


integration into the receiving
head, because integration
receiving head to disobey
decoding, signal amplifying
and shaping, so pay attention
to: in the absence of infrared signal, and the output end of the signal for a
high level to low level, so its output signal level just and a transmitting
terminal are anti. Receiving pulse end we can seen by the oscilloscope and see
the waveform of program understanding.

Line connection diagram:


Program code:
#include <IRremote.h>
int RECV_PIN = 11;
int LED1 = 2;
int LED2 = 3;
int LED3 = 4;
int LED4 = 5;
int LED5 = 6;
int LED6 = 7;
long on1 = 0x00FFA25D;
long off1 = 0x00FFE01F;
long on2 = 0x00FF629D;
long off2 = 0x00FFA857;
long on3 = 0x00FFE21D;
long off3 = 0x00FF906F;
long on4 = 0x00FF22DD;
long off4 = 0x00FF6897;
long on5 = 0x00FF02FD;
long off5 = 0x00FF9867;
long on6 = 0x00FFC23D;
long off6 = 0x00FFB047;
IRrecv irrecv(RECV_PIN);
decode_results results;
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN)
{
Serial.println("Could not decode message");
}
else
{
if (results->decode_type == NEC)
{
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY)
{
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5)
{
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6)
{
Serial.print("Decoded RC6: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");

for (int i = 0; i < count; i++)


{
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else
{
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
}

void setup()
{
pinMode(RECV_PIN, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver


}

int on = 0;
unsigned long last = millis();

void loop()
{
if (irrecv.decode(&results))
{
// If it's been at least 1/4 second since the last
// IR received, toggle the relay
if (millis() - last > 250)
{
on = !on;
// digitalWrite(8, on ? HIGH : LOW);
digitalWrite(13, on ? HIGH : LOW);
dump(&results);
}
if (results.value == on1 )
digitalWrite(LED1, HIGH);
if (results.value == off1 )
digitalWrite(LED1, LOW);
if (results.value == on2 )
digitalWrite(LED2, HIGH);
if (results.value == off2 )
digitalWrite(LED2, LOW);
if (results.value == on3 )
digitalWrite(LED3, HIGH);
if (results.value == off3 )
digitalWrite(LED3, LOW);
if (results.value == on4 )
digitalWrite(LED4, HIGH);
if (results.value == off4 )
digitalWrite(LED4, LOW);
if (results.value == on5 )
digitalWrite(LED5, HIGH);
if (results.value == off5 )
digitalWrite(LED5, LOW);
if (results.value == on6 )
digitalWrite(LED6, HIGH);
if (results.value == off6 )
digitalWrite(LED6, LOW);
last = millis();
irrecv.resume(); // Receive the next value
}
}

5, program function

The remote control launched encoding pulse decoding, according to the


results of the decoding of the corresponding action to perform.

Experiment screenshot:
note:
Put the

IRremote folder in the compiler to install the Arduinolibraries in the directory.。


For example :C:\Program Files\Arduino\libraries

You might also like