I R Hex codes won't print on monitor


#1

I have tried every example I can find ,but they all load properly .I get no print out with button push. Using ELEGOO uno R3 and this is the last sketch I tried.

#include <IRremote.h>
#include <IRremoteInt.h>

#include <IRremote.h> 
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
  if (irrecv.decode(&results))
    {
     Serial.println(results.value, HEX);
     irrecv.resume(); // Receive the next value
    }
}

#2

I’d check your wiring to make sure the ir receiver has power and its output is connected to I/O pin 11 as the sketch requires. If you have a Fritzing sketch, upload it (7th icon from the left on the reply menu) and one of us will look it over.

Peter


#3

Yes I have power and I forgot before, the remote is a CAR mp3

apparently it’s not a fritzing sketch cause it won’t let me upload it. When I try that Hello test that’s out there it prints like it’s should. Thanks for trying to help Me I;ve trying to gigure this out for over a week now and thinking maybe should go to R C.


#4

If you have a link to the schematic I’ll have a look. I’d start by making sure the IR receiver is providing output. Perhaps a led on the output pin (although I don’t know how much current an IR receiver will source or sink). Your most likely problem is there is no output. If there is output, then it may be in the wrong format. At present you could have either software or hardware problems. I’d first try and make sure the hardware works because if it doesn’t the software doesn’t matter. I think IR comes in a variety of formats too (although I’ve never played with IR), if your source is a different format from what the receiver and the software are expecting that also won’t work.

Peter


#5

This is the Llnk that I used for this sketch. I have the white remote .I put a led in the send line and it lights up .no buttons pushed. https://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/


#6

Are you using the receiver that came with the remote? If not that may be the problem, as the remote and the receiver need to be compatible. Then the receiver needs to be the same protocol as the arduino library is using. Does the led on the receiver blink when you press a button? As I recall the data runs at about 38khz which you may not be able to see on the led. The object is to make sure the receiver is putting out data.

edit:

You may want to try this script changing the port to 11. It should send a message to the serial port if the IR receiver is sending pulses. If it doesn’t the receiver is either defective or wired wrong or the IR transmitter isn’t working (try changing its batteries). If it does you are at least getting pulses so the hardware is doing something.

https://www.arduino.cc/en/Tutorial/StateChangeDetection

Peter


#7

Thanks peter I changed the receiver and still nothing when I push button BUT, when I pull the Signal wire out, I get Numbers like this.
DBC8CB72
F7DB926E
32D19EA0
FDACO150
49BOF624

It takes a long time a minute or more inbetween button pushes , but If I pull wire out I get a number.I also tried to see if the numbers are the same for a button 2 or 3 times and they are always different. By the way I did change the port to 11…I have another uno board here I’m going to try that with the recever it came with next. Thanks for your help, Gary


#8

So you are using the StateChangeDetection program above, with the pin changed to 11 and the IR receiver signal line connected to pin 11 and when you push the button on the remote nothing happens on the Arduino. If you disconnect the wire between pin 11 and the IR receiver the Arduino sees numbers but they are random. If pin11 isn’t pulled up, then the pin will float and you are likely to get random values. That would indicate the software is working and will detect state changes on the input. If nothing happens with the IR receiver connected, then that indicates there is a problem with the IR receiver or the IR remote (you might try new batteries in the remote) since no signal is getting to the IR receiver rather than something wrong on the Arduino side.

Peter


#9

I just finished up my design of EKG gizmo. Thus far, it’s setup for only One IR sensor (but can be expanded).
I learned a lot about the “Finickyness” IR from this project and provide some comments that may help:

• Using Elegoo Nano (and Elegoo UNO’s). Both work. For the Nano, it’s important to select the “Old Bootloader”

• I don’t use (or like) most libraries provided by users in Arduino - they are often specific to board&chip and IDE versions when the Open-Source author uploaded it. (I prefer doing my own code - most often in C++.)

• IR emitters (IR_LED’s, etc) are most often Paired with IR receivers - meaning, mixing Brands of IR sensors isn’t always successful.

• “Important” Most ‘User’ schematics show IR_Receiver Incorrectly! Check yours.

• There are two “AND” syntax’s: One for Logical operations and One for Bitwise operations. They are NOT mixable with certainty of outcome. Use the correct one.
“&” is for Bitwise
“&&” is for Logical

Also, Arduino IDE syntax changes in released versions so, I suggest placing a ‘space’ between ‘&’ or ‘&&’ and ‘Results. i.e., “ && results, Not “&&results”

I recommend starting with a simple AnalogRead of your IR_Receiver. The IR_Emitter can be supplied with a constant ‘High’ to keep it on - Be Sure to Use a Resistor - check spec’s for correct value. Easy to blow out an IR.
Most cameras (including Cellphones) will see the IR_emitter light as purple. That way, you’ll know if emitting. Receiver may also show purple.

IR hook-up and loading can be fussy and easy to blow them without proper resistance. Sure, you can get them to work then, after a few minutes, you’ll smell burning…

Note: I’m using an LM358 OpAmp for this project.

Images:
IR Emit & Rcvr on BB with LM358 to condition signal
IR On showing Purple
Gizmo on BB (Yes, my pulse is 50! That’s what got me started on an EKG project:laughing:

20190131_132247



#10

Quick follow-up…

I see you’re using pin 11. That is a Digital pin, the IR is an analog device. Without looking into the IR_Remote library you’re using, I don’t know if the author jimmied up something to use a Digital pin. But, I suspect, not. So, I suggest using an Analog pin for the IR input signal…


#11

The device he is using appears to be digital. The HX1838 has an open collector output driven by internal circuitry, it isn’t a photo diode alone (which is analog).

Peter


#12

I pulled out a similar IR receiver and hooked it up:

Mine needs signal amplification as the dig signal output on mine is too low to trip digital.

If his truly puts out a valid level, he can use a digital pin. Should do a simple digitalRead(11) in a basic code (as if it’s a button press).
Otherwise, amplify it if just a low level dig sig.

mov


#13

That would match what he is seeing, the code appears to work but doesn’t respond to the IR receiver indicating the problem is in the IR section rather than bad code. How low are the levels you are seeing (I don’t have one to try)?

Peter


#14

After some fooling around, I realized it was pumping out 4.64 V ( scope in photo show 1V increments (too many pieces of junk on my desk! ).

Attached shows Led blinking upon btn press from TV remote.
The IR_receiver is on the little white breadboard.
The serial printer (Arduino spits out a 1 upon btn press.
The video shows LED lighting up (and staying On while holding remote button).

CODE:
const int buttonPin3 = 3;
int ledPin3 = 7; // the number of the LED pin
int buttonState3 = 0; // variable for holding the IR or Button…etc response

void setup() {
pinMode(ledPin3, OUTPUT);
pinMode(buttonPin3, INPUT_PULLUP);
Serial.begin(9600);
}

void loop() {
buttonState3 = digitalRead(buttonPin3);

if (buttonState3 == LOW) {
// turn LED on:
digitalWrite(ledPin3, HIGH);
Serial.println(ledPin3);
}
else {
digitalWrite(ledPin3, LOW);
}
}//end

mov


#15

I suspect he has a problem with connections or code.

I am able to plot the signal using Arduino Serial Plotter. It’s the raw data (not scaled over the byte size…etc).

Signal from IR (similar to his with internal signal amplification - same one I used for previous test).

Signal is going into Arduino on Analog pin (though, it’s a High/Low digital from this IR). The signal shows up as expected…

CODE:
/*

  • Reads IR sensor
    */
    */
    int IR_sensorPin = A0;
    int ledPin = 7;
    int IR_sensorValue = 0; // variable to store the value coming from the IR_sensor

void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
IR_sensorValue = analogRead(IR_sensorPin);

Serial.println(IR_sensorValue);
// Serial.print(" ");

delay(5);
}//end

mov


#16

I suspect the connection, because with a led in there he didn’t appear to see any blinking and even at 38khz I think he should have. However, a beginner with no tools such as a scope or logic analyser and it doesn’t work (been there, done that, paying back the help I’ve gotten over the years :slight_smile: ).

Peter


#17

Well guys I’ve tried new IR senser and new Arduino uno and they don’t print when button on remote is pushed. The code complys and loads fine. But here is what happens when I take out the S pin and touch G pin ,when I pull ojj G It prints FCRBFFBF, I did it 4 times .the second time it printed FFFFFFFF ,the third time 869AE654 ,the 4th time FFFFFFFF…Could I need a resister or cap somewhere ? I wish I could find another code to find hex numbers of My remote. Are the hex numbers when found the same for all projects.? Gary


#18

It still sounds like the IR receiver isn’t outputting data. That could be because it is defective (but two of them makes that unlikely), or the IR remote is defective, has low battery or is otherwise not putting out a signal. Do you have a second IR remote to try? Does your remote have a light that lights on button pushes like the one that opera_night is using and if so does the light light up?

Peter


#19

No Light on remote ,but when I press button into cell phone camera I get a purple flash. It’s quit bright so I don’t think it’s battery .I wonder if the usb is not giving the Arduino enough power.


#20

If the arduino was having power problems you likely wouldn’t see any output when you connect the wire to the input port. That seems to indicate the arduino and code are OK and the problem is the IR receiver isn’t getting any data so it. I take it you don’t have access to an oscilloscope? Putting a scope on the Ir output as in opera_night’s video above is the best way to tell what is going on.

Peter