I have a SEN-10266 IR Receiver Diode - TSOP38238 from Sparkfun. I am trying to capture IR codes from my remote using an Arduino UNO R3. I have the ground and power from the IR receiver connected to the Arduino and the "out" from the receiver going to a PWM pin. I cannot see any codes coming across the serial monitor after I upload Ken Sherriff's IR sketch. Is it possible I am using the wrong receiver? I looked at the data sheet for the receiver and believe I have it hooked up correctly. Please advise. Thank you very much!
Shawn.
1st pin connected to out, 2nd pin to ground and 3rd pin to a 5v connection correct? Can you post a link to Ken Sherriff's IR sketch you're using please? Have you tried more than one remote?
Here is the code. I have used several remotes with no luck. Please let me know if you need anything else. Thanks.
#include <IRremote.h>
const int irReceivePin = 2;
IRrecv irrecv(irReceivePin);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if(irrecv.decode(&results))
{
showReceivedData();
irrecv.resume();
}
delay(250);
}
void showReceivedData()
{
if (results.decode_type == UNKNOWN)
{
Serial.println("-Could not decode message");
}
else
{
if (results.decode_type == NEC) {
Serial.print("- decoded NEC: ");
}
else if (results.decode_type == SONY) {
Serial.print("- decoded SONY: ");
}
else if (results.decode_type == RC5) {
Serial.print("-decoded RC5: ");
}
else if (results.decode_type == RC6) {
Serial.print("-decoded RC6: ");
}
Serial.print("Value = ");
Serial.println(results.value, DEC);
}
}
Please use the "insert code" button when pasting code. You can also write [code][/code] and place the code in between (Without the "*"'s).
The code you posted works fine for me.
Take a look at this picture: Imgur: The magic of the Internet
I hooked up my IR receiver like this, uploaded your sketch, opened the serial monitor and I see signals coming from a remotes whenever I click any button on the remote.. Please confirm this is how you have your arduino/IR setup.
partsofme: I will use the code button next time. I have it hooked up exactly like the image you posted. I don't get any errors when I upload it. I open serial monitor and press several different buttons on several different remotes and get nothing. Is there anything else I could be doing wrong? Thanks for hanging in there with me.
Try hooking up an LED (with a resistor, around 150 ohm is fine) to pin 3 and use this code:
#include <IRremote.h>
const int irReceivePin = 2;
IRrecv irrecv(irReceivePin);
decode_results results;
int led = 3;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
}
void loop() {
if(irrecv.decode(&results))
{
showReceivedData();
irrecv.resume();
}
delay(250);
}
void showReceivedData()
{
if (results.decode_type == UNKNOWN)
{
Serial.println("-Could not decode message");
digitalWrite(led, HIGH);
delay(30);
digitalWrite(led, LOW);
delay(30);
}
else
{
digitalWrite(led, HIGH);
delay(30);
digitalWrite(led, LOW);
delay(30);
if (results.decode_type == NEC) {
Serial.print("- decoded NEC: ");
}
else if (results.decode_type == SONY) {
Serial.print("- decoded SONY: ");
}
else if (results.decode_type == RC5) {
Serial.print("-decoded RC5: ");
}
else if (results.decode_type == RC6) {
Serial.print("-decoded RC6: ");
}
Serial.print("Value = ");
Serial.println(results.value, DEC);
}
}
The LED should light up whenever you press a button on a remote with this code, does the LED light up when you push a button on your remote?
What kind of remote are you using?
Even if the signal your remote is sending to the IR isn't valid, you should get a "-Could not decode message" message...
Have you tried testing your IR receiver?
Simplest possible test set-up here: