Lesson 8--Microduino Infrared Transmitting and Receiving

来自Microduino Wikipedia
跳转至: 导航搜索
Language English

Objective

This tutorial will teach you how to collect TV infrared remote control code, and sends the recorded infrared code.

Equipment

  • Microduino-Core
  • Microduino-FT232R
  • Other equipments:
    • Breadboard Jumper one box
    • Breadboard one piece
    • USB Data cable one
    • The infrared receiver one
    • Infrared transmitting tube one (Find it in old infrared remote controler)
    • Two resistors of 220 Ohm

The Infrared Receiver

第八课-红外接收器.jpg

Brief introduction: The infrared receiver is a kind of device which can receive the infrared signal and can independently from the infrared receiver to output signal compatibled with TTL level signal. Its volume is the sama as an encapsulation triode, suitable for all kinds of infrared remote control and infrared data transmission.

The Infrared Receiver Features:

  • Small size
  • Built-in dedicated IC
  • Received with wide Angle and long distance
  • Strong anti-interference ability
  • Withstand environmental interference
  • Low working voltage
  • Only three pin: Out, GND adn VCC, easy to connect to microcontroller

 1. The pulse signal output PORT, connect microcontroller IO port directly  2. GND connects to system GND  3. Vcc connects to system power (+5V)


Note:

  1. Storage and use in the absence of any external pressure and influence the quality of the environment.

  2. Storage and use of non-polluting gas or sea wind (salty) environment.

  3. Storage and use in low temperature environment.

  4. Under the specified conditions to welding the pin. After welding, do not apply force.

  5. Do not wash the product, before use connect the operator and the ground wire with electrostatic belt.

  6. Note infrared receiver receiving surface, contamination or wear will affect the reception, and do not touch the surface


Infrared Transmitting Tube

第八课-红外发射管.jpg

Brief introduction: Infrared transmitting tube is composed of infrared leds light, use material of high infrared radiation efficiency (commonly used gallium arsenide) to made PN junction, forward biased current injection to the PN to stimulate infrared light, the spectral power distribution as the center wavelength of 830 ~ 950 nm. Short for LED is Light Emitting Diode, performance is a positive temperature coefficient, the higher temperature with the greater current. the greater the size of the LED lamp power and current, but the forward current exceeds maximum value, the infrared lamp transmitted power will decline.

How to identify the pin:

Generally infrared transmitting tube has two pins, one is long, the other is short, like the LED diode. Long pin connects to the anode, short pin connects the cathode.

Experiment 1 - Infrared Receive

Schematic

第八课-Microduino红外接收原理图.jpg

Program

Download program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced/MicroduinoIRReceiver

//This example comes from infrated receive moudle's IRremote example
/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * [url]http://arcfn.com[/url]
 */
 
#include <IRremote.h>
 
int RECV_PIN = 11;//Define the infrated receive pin
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Initialize the infrated receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);//Output the receive value using hexadecimal
    Serial.println();//In order to watch the output increase a blank line
    irrecv.resume(); //Receive next value
  }
}

Debug

Step 1:Download IRremote library [1]

Step 2:Uncompress the library to libraries folder of Arduino IDE

Step 3:Set up the circuit

第八课-Microduino红外接收电路.jpg

Step 4:Open the program, compile it and download

Step 5:Open the serial monitor, infrared remote control toward to the infrared receiver and press different button.

Result

See infrared codes of different keys.
第八课-接收编码值.jpg


Experiment 2 - Infrared Send

Schematic

第八课-Microduino红外发送原理图.jpg

Program

#include <IRremote.h>                  // Invoke IRRemote library

IRsend irsend;                          // Define IRsend instance to send the infrared signal
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  3;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);  

  digitalWrite(ledPin, HIGH);   // ligth LED(ObservE by mobile phone camera mode)
  delay(3000);             // Wait for 3s
  digitalWrite(ledPin, LOW);    // the end of testing  
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
    Serial.print("SendIR: ");
    irsend.sendNEC(0x234E817, 32); //9
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Debug

Setp 1:Download IRremote library [2]

Step 2:Uncompress the library to libraries folder of Arduino IDE

Step 3:Set up the circuit

第八课-Microduino红外发送电路.jpg

Step 4:Open the program, compile it and dowanload

Step 5:Press the button, infrared transmitting tube will launch infrared coding, due to the infrared light invisible to the naked eye, but can be seen in the camera.

Result

With a button to control whether to send infrared, press the buttuon infrared tubes will send the infrared code that you set.

Video

http://v.youku.com/v_show/id_XNjc1NjQ1Nzg0.html