yt_link
insta_link
fb_link
twitter_link

Receiver code


Receiver 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 receiver code:




This code is for the schematic.




/* Electronoobs IR receiver code. Read the AURT signal from the IR module
 *  Baud rate low: 300 bauds. se schematic below:
 *  http://www.electronoobs.com/eng_arduino_tut35_sch2.php*
 */

//I/O
int left_top = 2;
int left_mid = 3;
int left_bot = 4;
int right_top = 11;
int right_mid = 12;
int right_bot = 13;

//Received codes for each button. Make sure ar the same as in Tx code
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;

//Digital write state of each LED; false = LED OFF
bool LEFT_TOP_STATE = false;
bool LEFT_MID_STATE = false;
bool LEFT_BOT_STATE = false;
bool RIGHT_TOP_STATE = false;
bool RIGHT_MID_STATE = false;
bool RIGHT_BOT_STATE = false;

//This is where we store the received byte
byte received = 0;

void setup() {
  Serial.begin(300); //Baud rate has to be low
  pinMode(left_top,OUTPUT);
  pinMode(left_mid,OUTPUT);
  pinMode(left_bot,OUTPUT);
  pinMode(right_top,OUTPUT);
  pinMode(right_mid,OUTPUT);
  pinMode(right_bot,OUTPUT);

  //Turn off all LEDs
  digitalWrite(left_top,LOW);
  digitalWrite(left_mid,LOW);
  digitalWrite(left_bot,LOW);
  digitalWrite(right_top,LOW);
  digitalWrite(right_mid,LOW);
  digitalWrite(right_bot,LOW);
}

void loop() {
  //If the serial is available and with a value > 0 we read the byte in
  if(Serial.available()>0)
  {
    received = Serial.read();    
    //Serial.println(received); //uncomment for debug

    //If the received byte is one of the codes, we change the LED state
    if(received == LEFT_TOP_CODE)
    {
      LEFT_TOP_STATE = !LEFT_TOP_STATE;
    }
    
    if(received == LEFT_MID_CODE)
    {
      LEFT_MID_STATE = !LEFT_MID_STATE;
    }
    
    if(received == LEFT_BOT_CODE)
    {
      LEFT_BOT_STATE = !LEFT_BOT_STATE;
    }
    
    if(received == RIGHT_TOP_CODE)
    {
      RIGHT_TOP_STATE = !RIGHT_TOP_STATE;
    }
    if(received == RIGHT_MID_CODE)
    {
      RIGHT_MID_STATE = !RIGHT_MID_STATE;
    }
    if(received == RIGHT_BOT_CODE)
    {
      RIGHT_BOT_STATE = !RIGHT_BOT_STATE;
    }

    //Turn on or off the LEDs depending on the states
    digitalWrite(left_top,LEFT_TOP_STATE);
    digitalWrite(left_mid,LEFT_MID_STATE);
    digitalWrite(left_bot,LEFT_BOT_STATE);
    digitalWrite(right_top,RIGHT_TOP_STATE);
    digitalWrite(right_mid,RIGHT_MID_STATE);
    digitalWrite(right_bot,RIGHT_BOT_STATE);    
  }
 

}


Arduino infrared receiver tutorial







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€