Infra Red sender code

Hello ,

I wrote a code that if an input is HIGH,the IR send a code on HEX to a reciever,but it’s not working.

Could someone help me.

this is the wrong code:

#include<IRremote.h>
IRsend irsend;

int Send_PIN=2;

void setup()
{
  pinMode(digitalRead(13),INPUT);
  pinMode(digitalRead(12),INPUT);
  pinMode(Send_PIN,OUTPUT);
  
}

void loop ()
{
  if(digitalRead(13) == HIGH)
  {
    irsend.sendSony(0xa00,13);
    delay(50);
  }
  
  if(digitalRead(12) == HIGH)
  {
    irsend.sendSony(0xa01,13);
    delay(50);
  }
}

This isn’t right…

  pinMode(digitalRead(13),INPUT);
  pinMode(digitalRead(12),INPUT);

but this is…

  pinMode(Send_PIN,OUTPUT);

Notice the difference?

After you send you must re-enable receiving.

The solution should be mentioned in the "pitfalls" document via my signature or just search.

Of course, you should also take the advice of @Martin-X & you will also need to define Send_Pin