Panel Cookies
yt_link
insta_link
fb_link
twitter_link

Transmitter code

Una publicación compartida de ELECTRONOOBS®️ (@electronoobs) el


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 PCB service





Curso Arduino Online nivel bajo