In an earlier post I showed how to generate high frequencies with Arduino (or an ATMEGA controller). This trick can be used to make the 40KHz (or similar) modulation used to transmit infrared remote control signals.
By placing a simple infrared diode between pin9 and some other pin on the diode os either off when the pin is high or modulated by the 40KHz signal when it is low.
Very conviently data from the TX (pin 1) or RX (pin0) can be used to drive the LED thus allowing data from either Serial on the microcrontroller or the USB to modulate the signal.
On the receiving side an integrated infrared receiver such as this one convert the modulated light to data.
I have found that with the suggested receiver it is possible to directly transmit serial data at 1200 BAUD.
Here is some Arduino thest code:
//**************************************************************
// Using AVR ATMEGA hardware to generate IR modulation
// Dzl 2013
//**************************************************************
void setFrequency(int d)
{
//Frequency = 16000000/d
TCCR1B&=0xfe; //-Stop generator
TCNT1=0; //-Clear timer
ICR1=d; // |
OCR1A=(d/2); //-+
TCCR1B|=0x01; //-Restart generator
}
void setupFrequencyGen()
{
TCCR1A=0b10000010; //-Set up frequency generator
TCCR1B=0b00011001; //-+
setFrequency(16); //-Start with 1MHz
pinMode(9,OUTPUT); //-Signal generator pin
}
void setup()
{
setupFrequencyGen();
setFrequency(444); //-Make 36KHz
Serial.begin(1200);
}
void loop()
{
Serial.println("Testing the dirty IR link");
delay(1000);
}
No comments:
Post a Comment