I R Hex codes won't print on monitor

Let’s do Two Clean Test’s, as follows:

Assume Remote Control, IR and Uno are good.

Hook-Up:
Plug in the IR (put into a BreadBoard or hook up with wires). Your IR receiver has Pre-Amplification so, NO Resistor or Cap is needed.

See below image of Hook-up.
(V=5v, GND, Signal_Out).

Test#1 (Digital with LED or Buzzer):
Signal_Out goes to D3 on UNO.
Get the 5volts (for the IR) from the UNO pin labeled 5volts and the GND from the pin labeled GND.
Note: the GND Must be common to UNO and IR_receiver and LED, not separate circuits).

Run the first Code I posted - Press a button on Remote; The LED on breadboard should flash momentarily.

Test#2 (Analog with Serial Plotter display):
Signal_Out goes to A0 on UNO, GND and 5volts, as above).
Common GND, as above.

Run the second Code I posted. Select the Serial_Plotter from Arduino>Tools>Serial_Plotter (this is not the same as Serial_Monitor).
Press a button on Remote - you should see Spiked lines on the display.
NOTE: Although not needed, it’s cleaner if you scale the signal in the code:
Replace: IR_sensorValue = analogRead(IR_sensorPin);
With this: IR_sensorValue = analogRead(IR_sensorPin) * 5/1023;

(or, simply adding the “ * 5/1023 “ to end).
Display will look like below…


Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\frank\AppData\Local\Temp\ccEdkhNY.ltrans0.ltrans.o: In function `main’:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop’

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
I got the Error message for the first one .The second one I got up and down lines scrolling across screen steady but I never touched a button on the remote…I have tried a different remote the same kind and a different recever .with a different code I found and there again I had numbers just coming on serial steady with out touching a button on remote. I will post code for you to check cause I don’t know what to do to stop steady scrolling .I tried stop scroll on serial but that didn’t help.

#include <IRremote.h>
#include <IRremoteInt.h>
#include <IRremote.h> //including the remote library
int receiver_pin = 2; //output pin of IR receiver to pin 2 of arduino
IRrecv receiver(receiver_pin); //Arduino will take output of IR receiver from pin 2
decode_results output;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  receiver.enableIRIn(); // Start to take the output from IR receiver
}

void loop() {
  if (receiver.decode(&output)) {
    unsigned int value = output.value;
    Serial.println(value);
    receiver.resume();
  }
}

Do this:
In Arduino;
File>New
Select all the code in the New window and delete it.
Paste one of the codes I posted (First try the first code, paste all of it).
Save the file.
Click the Verify icon and see if errors.

If no errors, upload it to UNO and follow previous instructions.

If getting continuous bars, it sounds like your pulling down the port (A0 or D3). Check your connections.

If using Code#1, Reading the IR sensor is nothing more or different than reading a Button press so, you can also grab one of the Examples for a button/blink test (just ensure to change to proper Port/Pin).

FOLLOW-UP: I noticed (again) you are not putting a space after the “&”. The IDE will not necessarily (probably won’t) recognize it as anything other than a Text character without a space. Also, you are doing Logical expression. Must use " && " for logical… but, what you have (&someText) is neither a logical nor, bitwise expression (and, without my looking into the IR remote code, I can’t say for sure that is is Not correct for that Library).

But, again, do the simple tests I indicated before messing with IR_Remote…etc

OK I did what you said and the first code loaded fine and all complied fine. but when I push button on remote nothing happens no light either. the second code did everything it did the first time .constant sig sag lines up and down scrolling fast across the middle part of plotter screen. I’m quit sure I have it hooked up right going to add some photos if I can. Is it right for 2 other lights come on blinking on the Arduino and then a light closest to the plugs stays on when finished loading. .I’m beginning to think both receivers are bad. I’m very surprised no one else has trouble getting hex codes for there remotes .I thank you again , Gary

![DSCF0089|690x460](upload://erXAJpmOEevoa6rvAHomoyYz5SZ.JPG

Quick note - I’m out for the rest of evening. But, Yes. The TX & RX lights should be on (indicating serial data going in and out). The D13 (default LED on board) is not coded to light up - in my sample code).
There’s a power LED on board that also lights up.

If you make clean connections as indicated in my handwritten image, it should work. I sounds like you have miss wired something. For the LED, use a Resistor or it will blow out (may have already blown). 200 to 330 Ohms is a good value to use. The photo isn’t clear so I can’t see if one is there… And, remember, one leg is Anode, other is Cathode (GND).

I’ll get back tomorrow…

It is beginning to sound like both IR receivers may be dead. They are sensitive to polarity, if they are connected backwards (+5V to ground ground to +5V) there is a good chance they will burn out. With the code that scrolls continuously, you could try disconnecting the signal wire from the Ir receiver and replacing it with a resistor (pretty much any value) between the signal pin and +5V. That should give an always high signal, which should in turn should not cause any scrolling, because I think that is the default off state of the IR receiver. If it doesn’t then try connecting the resistor to ground and see if it still scrolls. If neither of those stops the scrolling then there is something wrong with the code and you need to fix that before deciding the receivers are both dead. If it stops scrolling when high, then moving the resistor to ground should start it scrolling again (maybe, I’m not sure if it is looking for pulses or not) at the least is should scroll some as the connection is made. If that happens then the software is working correctly and likely the problem is with the IR receivers.

Peter

Peter I will try your suggestions but first I want ,opera_night to see new photo of My hook up .Everything complys and loads great but pushing remote button don’t light led. I have tried 3 IR receivers and 2 of the same kind remotes both new and none will light the new led. I have 4.5 volts going to receivers etc,.maybe not enough ? On the Arduino what are - pins for ?

Sort of a ‘Shame on me’ :frowning_face: I took a look around the Net and find similar Ir sensors. But, some have different pinout’s versus mine. I googled the spec for HX1838 and finally found a spec - image of pinouts attached.

Also found a setup on UNO with wiring compatible with the pin’s.

I think if you simply switch the physical Pin’s it will work. Of course, hook it up so it matches the Pinouts on the UNO (or change them in the code). I would try different hook-up’s as some on net are different enough and I don’t know where you got your’s (and, of course, if they’re from China, well…

Not sure what you’e asking "On the Arduino what are - pins for ? "

This may help (NOTE: the ir on the breadboard looks like an LED. I just grabbed something with 3 pins to show you. Ensure your device has same pins or swap them… Fritzing file attached



forU.fzz (5.3 KB)

Your wiring looks correct for the HX1838 as far as I can see. The only suggestion I could make is try a resistor of about 20k from pin 1 (signal) to pin 3 (+5V). The signal lead is open collector, and if the arduino pin isn’t pulled up (which I think they by default should be), this won’t work because signal won’t ever go high. Then again a look at the HX1838 data sheet says it has an internal pull up resistor so that shouldn’t be the problem. At this point I don’t know what is wrong. Does the IR receiver have a part number on it, and if so is it a HX1838? Looking back I see that the HX1838 is what the sketch you referred to used, not necessarily what your unit is, and that may be the problem if you have another receiver with a different pin out this won’t work.

Peter

Peter My receiver say number VS 18388

Agree.

I think a good starting point would be to confirm “ZNEB” can do a simple Blink of LED to confirm a general understanding of Pull-up and Pull-down.

Two schools: One group likes Pull-up the other likes Pull-down. Arduino likes Pulling-down for a signal (say from a Button press). Although both (Up or Down) will work - just depends on code and wiring.

FYI However, Arduino IDE/Syntax has a nice feature. You can Pull-up(10k ohm) a pin as default - it’s done in code so No external resistor is used. Primarily for Buttons but anything where it makes sense.
As follows (example for pin D5):
Without pullup: pinMode(5, INPUT);
With pullup: pinMode(5, INPUT_PULLUP);

I found this datasheet - screenshot below

Well at least we didn’t give you bad hookup advise, as @opera_night said the data sheet indicates it is the same pinout as the HX1838, so that should be fine. It does however still leave me at a loss about what is wrong, since it looks right and should work, but doesn’t. I think we need to find a way to confirm that something is coming out of the IR receiver when the buttons are pushed on the IR remote. The cell camera seems to have verified the remote is putting out IR (whether it is the correct format for the library is still in question though), but so far we haven’t seen confirmation that the IR receiver is getting data in to the arduino, and I think that is the next step. I’m just at a loss about how to do that. @opera_night if you put a led across the signal output of your IR receiver and push the remote can you see the led flicker or is the pulse too quick to see (at 38Khz I suspect it may go by to fast)? If the led flickers for you that would test the IR receivers for him indicating the problem is further along the chain. I’m thinking that a diagnostic sketch that will detect pulses on an input pin on the arduino would be a good bet here, but I don’t know of one (I use a scope or a logic analyser to do this :slight_smile: ). A quick google search doesn’t turn up anything likely though, although my search term may be wrong as this should be a common need for folks without a scope.

Edit:

This post suggests that a led on the output of the IR receiver should produce visible flashes when the IR remote is pressed. I’d suggest trying that.

You can use the 5V from the Arduino in place of the batteries they show here, connect a led and a 220 ohm resistor in series with it from +5V to the signal pin. No flashes likely means a dead IR receiver.

Peter

  1. Yes, with an LED across GND and SigOut, a constant glow that quickly flickers when button press on remote control. Note: I did it with different LED’s having different Forward voltages and currents. The one in the photo is the best of them…

  2. The Code#2 is a good poor-man’s approach to O’Scope. Cleaner version below.
    At button press on remote, Serial _Plotter shows bars pulled down from 5V(approx) to 0v.
    It is for an Analog signal into Arduino. The Code#1 is for Digital signal into Arduino.
    Between the two, with proper hook-up, signal will be seen in serial plotter for analog or on LED for digital.

  3. I found some remote control’s folks are using for this simple stuff and DISCOVERED that some run oscillators at 455Hz. I /we don’t really know what IR or Remote ZNEB has.
    link:Link to one

{FOLLOW_UP} I downloaded and ran the Code from link Vanepp posted. Code ran fine and displayed as supposed to…

Cleaner Code:
/*

  • Reads IR senso on Analog Pin*/

int IR_sensorPin = A0;
int IR_sensorValue = 0; // variable to store the value coming from the IR_sensor

void setup() {
Serial.begin(9600);
}//end setup

void loop() {
IR_sensorValue = analogRead(IR_sensorPin) * 5/1023;
delay(5);
Serial.println(IR_sensorValue);
}//end loop

IR and LED shown in box at top…
27%20AM

I have 2 of what the photo posted shows CAR mp3. I don’t have the blue SQ. chip what ever it is. I tried both on all the former examples and they don’t work as stated . I don’t know much about writing code but I tried changing things as suggested but no luck. I may have the wrong libraries loaded I know I saw some where that if you have some robot ones they create problems but I can’t delete out of sketch when they come up. Robot IR Remote and Robot Control are the 2 I saw .Led across GND lites but no fliker with button push… Thanks guys Gary

If the led doesn’t flicker when the remote button is pushed, I’d guess the IR receiver is dead, and the libraries aren’t going to matter (at least yet :slight_smile: ) because there is no data coming in. You need to get the receiver to work and then move on the to the libraries if needed.

Peter

This is interesting I tried My other receiver and it blinks once and go off when I insert it but not with button. I also have a black receiver like in your photo and when I insert that it keeps blinking without touching the remote.

Sounds to me like:

  1. Very simple to solve
  2. Difficult to solve without parts on desk
  3. Mixture of Parts and Codes and skill/knowledge

However, I’ll say this:
Although Coding can be confusing (esp for newbie) it isn’t difficult to move forward if a plan is in place.

So, though most of what we’ve been going over and will come up is better suited for, perhaps the Arduino site (or other), I’m happy to respond here as it enables providing some usable Fritzing files for testing.

That said, consider this as a Plan:
Grab these parts:
• UNO
• LED
• Resistor (100 to 330 ohms, approx range)

In Arduino, Load an Example Blink sketch.
This sketch does NOT use additional parts listed above.
I simply used the LED on the UNO.
You will understand how to set it for displaying (On/Off).
The comments in Code are useful and there is a link…

Once successful, now Tweak the Code lines where it says "LED_BUILTIN " Three places to change it.
Replace them with the simple number 13.
The Same LED on UNO should blink as before.

What did we do? The code has LED_BUILTIN hard coded to pin D13 in Arduino.
All we did was to Hand code it instead.
So, when someone say’s change the pin to D5, you look at your code, find all the places where what you want to change is located and, simply change them to 5. Note, depending code, IDE version…etc, You may also be able to use D5 instead of just 5

Now, install the Resistor: One leg to GND, the Cathode (short leg with little Flat edge on Plastic rim on LED.
Attach the Anode long leg) to whatever pin you want (don’t use D13. Though you could, let’s not complicate it).
Change the Code to reflect the desired Pin.

Compile and you should see it blink instead of the LED on the UNO.

Now, going back to Codes I posted…
For testing, you have a choice:
Use Digital pin or Analog pin.
Since your IR has a preAmp, it can put out a signal level high enough to flip.
For Digital test use whatever Digital pin you want but ensure you change the code to call out the same pin number.
For Analog test use an Analog pin and ensure code calls the same number.

39%20PM

There are other Example codes to explore…

Once certain that Blinking happens with LED and gained knowledge of above, working on the IR will be easier to solve as ‘we’ will have a foundation of events that clearly form the basis of this stuff.

The Next step, however, would be to implement a Button to press and cause the LED to blink. Then, it’s little more than hooking up and clear coding the events… The IR receiver is simply much like a Button press…

I ordered These IR’s from Amazon two days ago.
They arrived today and I hooked one up and, Bingo!
They respond just as my other brands do - They Work!
Works with my TV remote control… and the Code I posted.

They are marked (stamped on back) 1838.

For ‘kicks’, I fried one (by reversing GND and Vcc). It got so hot I burned my fingers. Now, running in with my codes, I get lot’s of lines (probably like ZNEB is getting). Thus, I suspect his are toast!

Mine are marked 1838B ,I wonder if that’s why I’m having trouble. I have success with your first test but not the other also I found a test for printing yes or no that worked to test monitor read out .I wonder if I need this type of receiver to get hex codes ? Photo

Well, some progress…

If the first code runs ok then, Load the second code, and change the wiring on the

Arduino: Plug the wire, that went to D3, into A0. And upload(Compile) the code, it should run.

NOTE: Run the second code as indicated but, Use the Serial Plotter (not Serial Monitor) for this test.