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 JGAURORA A3S Fully Metal LCD Display Control DIY 3D Printer
JGAURORA A3S Fully Metal LCD Display Control DIY 3D Printer only $299.99
Gearbest Geeetech E180 Mini 3D Printer with WiFi Module
Geeetech E180 Mini 3D Printer with WiFi Module only $245.99


Gearbest JGAURORA A5X 3D Printer Kit Printing
JGAURORA A5X 3D Printer Kit Printing only $379.99


Gearbest Min DS202 Oscilloscope 113€
Min DS202 Oscilloscope 113€


Gearbest UTD2052CL DIGITAL 2-ch Oscilloscope 275€
UTD2052CL DIGITAL 2-ch Oscilloscope 275€


Gearbest UT139C True RMS Digital Multimeter 29€
UT139C True RMS Digital Multimeter 29€


Gearbest SBK8586 Soldering station Hot Air + Iron 63€
SBK8586 Soldering station Hot Air + Iron 63€


Gearbest BAYANGTOYS X21 Brushless RC Quadcopter
BAYANGTOYS X21 Brushless RC Quadcopter 153€