Arduino Lesson 20: IR LED
Arduino Lesson 20

IR LED

Receiving data from IR

Components Required

Buy

Introduction

IR or Infrared is commonly used in communication technology in many cases. Because it is inexpensive and easy. Because this technology is dependent on light, this is widely used for short-distance communication. The IR LED module emits Infrared light in slightly higher frequencies. So it uses to transmit data and using the IR receiver, we can take that data from another place.

Learning outcomes:

  • Using IR LED and getting transmit data
  • Apply IR LED in projects

Theory

IR light has a slightly high wavelength than visible light. So we can’t see IR light. Also, it has a high-frequency range. Therefore, using IR light, we can transmit data from a high-frequency waveform. This is called modulated signal transmits. The sun and every light source emit IR light. IR light is always around us, with many higher frequencies. Therefore, in the communication, we used some rare natural IR frequencies. In many cases, 38KHz is used. In this frequency, the IR LED is on and OFF 38000 times in a second. The encoded modulated data(binary data) is transmitted by changing on and off patterns. Then this wave is receiving and demodulate by using an IR sensor. After using some microcontroller, we can decode and know what is the transmitter side has sent.

https://cdn.sparkfun.com/r/600-600/assets/4/1/6/1/c/5159e980ce395f8840000000.jpg

Methodology

Connect the IR LED module to Magicbit. As usual, we connect this module to the upper right connector(D33) of the Magicbit. Download and install IR remote library from here. Then connect the Magicbit to your pc and upload the following code. This code is used to transmit some data to some other device like TV, A/C or etc. When the right push button is pressed. According to your purpose, change the binary code to change the data that you want to transmit.

Code

 

#include<IRremote.h>

#define PB_Right 34;
#define IR_SEND_PIN 33;
boolean buttonState;
long irKeyCode= 16582903;
IRsend irsend;

void setup(){
pinMode(PB_Right, INPUT);
Serial.begin(9600);
}

void loop(){
buttonState=digitalRead(34);
if(buttonState==LOW){
        irsend.sendSony(irKeyCode, 32);
        Serial.println("Sending");
        delay(40);
        }
}
Related Posts
Leave a Reply