Using IR receivers with Arduino
hi guys! in this tutorial we are gonna see how IR receivers work and how we can control them with the help of an Arduino
IR Receivers:
The above picture shows an IR receiver IR stands for Infra RED which is before the visible red light in the light spectrum
INSIDE AN IR RECEIVER:
The above diagram shows the inside of an IR receiver.there is an photo-diode that detects the IR light from the outside and the other components are just filters
THE IR TRANSMITTERS:
an IR transmitterthe IR transmitter is simply a light emitting diode which emits IR light
These IR lights which are generated by the IR transmitters are recognized by the IR receivers
but wait,IR light is everywhere!the sun produces Infra red light.
so,these IR transmitters blink at some certain frequency.they are usually 32kHz band.
see my you tube video for more information watch video
controlling the reciever with Arduino
#include <IRremote.h>int IRpin=9;IRrecv IR(IRpin);decode_results cmd;String myCom;void setup(){Serial.begin(9600);IR.enableIRIn();}void loop() {while (IR.decode(&cmd)==0){}Serial.println(cmd.value,HEX);delay(1500);IR.resume();if (cmd.value==0xFF6897){myCom="zero";Serial.println(myCom);}if (cmd.value==0xFFA25D){myCom="pwr";Serial.println(myCom);}}
Copy this code and paste it in the Arduino IDE
before uploading the code,Make sure that you downloaded the IR remote library.click here for direct download
And you are done!now take your remote and press a button.at the same time open the serial monitor.the codes are the decoded codes that has been generated while pressing a button in your TV remote.now you can use these codes by copying them from the serial monitor to makeyour own piece of code which simply on/off an LED






Comments
Post a Comment