Go Down

Topic: IR transmitter Manchester Encoding (Read 1 time) previous topic - next topic

kashyap

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.

Targettio

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.

https://github.com/shirriff/Arduino-IRremote

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview