IR Transmitter Circuit with Arduino FAILED

Hi,
I followed this tutorial to make transmitter and receiver IR circuit using Arduino.

For transmitter circuit I used this:

For Receiver circuit I used the modified version of this:


I used VS1838 IR sensor for receiver. BUT the transmitting part failed.
Transmitter code:

/*
  IR Transmitter Demonstration 1
  IR-Xmit-Demo1.ino
  Control TV using IR Library
  IR LED must use Pin #3
  DroneBot Workshop 2017
  http://dronebotworkshop.com
*/

// Include IR Remote Library by Ken Shirriff

#include <IRremote.h>

// Define switch pin
const int switchPin = 7;

// Define a variable for the button state
int buttonState = 0;

// Create IR Send Object
IRsend irsend;

void setup()
{
  // Set Switch pin as Input
  pinMode(switchPin, INPUT);
}

void loop() {
  
  // Set button state depending upon switch position
  buttonState = digitalRead(switchPin);
  
  // If button is pressed send power code command
   if (buttonState == HIGH) {
    irsend.sendNEC(0xFEA857, 32); // TV power code
  }
      
    // Add a small delay before repeating
    delay(200);
 
} 

Receiver code:

// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>

// Define sensor pin
const int RECV_PIN = 4;

// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;


void setup(){
  // Serial Monitor @ 9600 baud
  Serial.begin(9600);
  // Enable the IR Receiver
  irrecv.enableIRIn();
}

void loop(){
  if (irrecv.decode(&results)){
    // Print Code in HEX
        Serial.println(results.value, HEX);
        irrecv.resume();
  }
}

You missed that this sensor is more than a simple photo diode. You have to use the IRremote library to send RAW data, then it works. Or use a simple receiver diode as shown in the reference.

I moved your topic to an appropriate forum category @john1n.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

1 Like

I am already using the IRremote library. I think there was some ambiguity in my post. So, I edited the post.

use INPUT_PULLUP for your button input and rewire the switch between the input pin and ground. Get rid of the resistor on the switch. Test for digitalRead(_) == LOW in your code for button pressed.
There may be other issues, but that should be a start.

Hi,
I already checked the functionality of switch by putting print function in "If" block. The problem is not from the switch as Serial.println("Here") prints "Here" after pushing button.

Bump your serial baud rate up, to 115200 too.
You might want to wait for button release instead of just doing a delay in your send.

@john1n

Show us good images of your actual wiring.


Tried. Not working. I think I need to try another IR receiver sensor type like TSOP382 too.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.