Hi,
I am making a simple IR transmitter using infrared LED.
I am able to generate simple PWM but I want PWM for specific bit.
For example I want send 10010100 how should I generate manchester (0r any other easy bit encoding scheme).
Here is my simple code using key denouncing.
int pinout = 12;
int pinout_pwm = 9;
boolean send_pulse =false;
void setup()
{
pinMode(pinout, OUTPUT);
pinMode(pinout_pwm, OUTPUT);
pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
attachInterrupt(0, check_event, FALLING);
Serial.begin(9600);
}
void loop()
{
if(send_pulse)
{
digitalWrite(pinout, HIGH);
Serial.println("One pulse send");
pinMode(3, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);
OCR2A = 110;
OCR2B = 110;
send_pulse = false;
delay(8);
pinMode(3, INPUT);
//generate_PWM();
}
else
{
digitalWrite(pinout, LOW);
}
}
void check_event()//Interrupt service routine
{
send_pulse = true;
}
Any help would really be appreciated. Thank you very much.