yt_link
insta_link
fb_link
twitter_link

Transmitter code


Transmitter IR remote - CODE


Help me by sharing this post





Download the .zip file below. Open it on your Arduino IDE and upload it to the Arduino and make sure you have the connections as in the schematic. Also, read all the comments in the code to understand more. You could also copy and paste the code from below.

Download transmitter code:




This code is for the schematic.




/* IR remote. It uses and IR led to send data. It is made for
 * 6 push buttons with pullodonw to GND of 1k. 
 * Schematic: http://www.electronoobs.com/eng_arduino_tut35_sch1.php */
//i/O 
int left_top = 2;
int left_mid = 3;
int left_bot = 4;
int right_top = 5;
int right_mid = 6;
int right_bot = 7;

//Codes to send. Change if you want. Up to 8 bits so 0-255
byte LEFT_TOP_CODE = 0x04;
byte LEFT_MID_CODE = 0x08;
byte LEFT_BOT_CODE = 0x0C;
byte RIGHT_TOP_CODE = 0x10;
byte RIGHT_MID_CODE = 0x14;
byte RIGHT_BOT_CODE = 0x18;

void setup() {
  Serial.begin(300);
  pinMode(left_top,INPUT);
  pinMode(left_mid,INPUT);
  pinMode(left_bot,INPUT);
  pinMode(right_top,INPUT);
  pinMode(right_mid,INPUT);
  pinMode(right_bot,INPUT);
  //Turn OFF the TX pin so the IR LED will be OFF
  pinMode(0,OUTPUT);
}

void loop() {
  //If one button is pressed, we send one byte corresponding to that button
  if(digitalRead(left_top))
  {
    Serial.write(LEFT_TOP_CODE);
    delay(500);//Small delay, we make sure we won't send it twice 
  }


  if(digitalRead(left_mid))
  {
    Serial.write(LEFT_MID_CODE);
    delay(500);//Small delay, we make sure we won't send it twice 
  }

  if(digitalRead(left_bot))
  {
    Serial.write(LEFT_BOT_CODE);
    delay(500);//Small delay, we make sure we won't send it twice 
  }
  

  if(digitalRead(right_top))
  {
    Serial.write(RIGHT_TOP_CODE);
    delay(500);//Small delay, we make sure we won't send it twice 
  }
  

  if(digitalRead(right_mid))
  {
    Serial.write(RIGHT_MID_CODE);
    delay(500);//Small delay, we make sure we won't send it twice 
  }
  

  if(digitalRead(right_bot))
  {
    Serial.write(RIGHT_BOT_CODE);
    delay(500);//Small delay, we make sure we won't send it twice 
  }

  //Turn OFF the TX pin after each data send, sod the IR LED will be OFF
  digitalWrite(0,LOW);
}


Arduino infrared remote homemade







ADVERTISERS
PCBWay Ad

AFFILATE

Gearbest SG - 700 Satellite Navigation Foldable RC Drone Quadcopter - WHITE 720P WIFI FPV CAMERA
SG - 700 Satellite Navigation Foldable RC Drone Quadcopter - WHITE 720P WIFI FPV CAMERA only $46.99

Gearbest Xiaomi AMAZFIT Heart Rate Smartwatch - BLACK INTERNATIONAL VERSION
Xiaomi AMAZFIT Heart Rate Smartwatch - BLACK INTERNATIONAL VERSION only $89.99

Gearbest FeiLun FT011 2.4GHz Brushless RC Racing Boat - BLACK AND WHITE AND RED
FeiLun FT011 2.4GHz Brushless RC Racing Boat - BLACK AND WHITE AND RED only $96.99