Pages: [1]   Go Down
Author Topic: IR transmitter Manchester Encoding  (Read 1458 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);

void loop()
  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;
    pinMode(3, INPUT);
    digitalWrite(pinout, LOW);

void check_event()//Interrupt service routine
  send_pulse = true;

Any help would really be appreciated. Thank you very much.

Offline Offline
Jr. Member
Karma: 1
Posts: 95
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The simplest way to do what you want is to use the IRremoete library and send raw codes.

The library handles all the timing aspects. But if you want to learn how to do it yourself, the library may also be a good starting point.

Pages: [1]   Go Up
Jump to: