Hey, I've hooked up an IR sensor to my arduino uno and have a remote to go along with it. They both came in this starter kit: https://www.microcenter.com/product/617046/inland-basic-starter-v2-kit-for-arduino-uno. I went to the guide for the sensor and hooked it up as advised and tried to get output to the Serial Monitor although I haven't been having any luck. I have the rightmost pin connected to 5v through the breadboard, the middle pin connected to ground through the breadboard, and the leftmost pin connected to pin 9 straight on the arduino. Here is a link to my code for reference. ArduinoLCDRemoteProject/test.ino at main · Jack-Gitter/ArduinoLCDRemoteProject · GitHub. I went to the documentation for the specific IR reader that I have Ks0069(72, 73) keyestudio Basic Starter Kit for Arduino Starters - Keyestudio Wiki (specifically project 14) and it said to connect the leftmost pin to an analog input, although the diagrams show them connecting it to digital. I've tried both and adjusted my code accordingly but still no luck. Any help greatly apprecitated.
Show us a good image of your ‘actual’ wiring.
In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.
Here is the code, although as for the wiring i also have an lcd attached and I only have the quite long wires that come with the starter kit, so it would be quite impossible to see anything from just a photo. But I can assure you that I have hooked the wires up as I described in the post 100%.
#include <LiquidCrystal.h>
#include <HashMap.h>
#include <IRremote.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
const byte HASHSIZE = 8;
int RECV_PIN = 9;
IRrecv irrecv(RECV_PIN);
decode_results results;
enum Person {
Jack, Chris, Mason, Will, Evan, Nick, Declan, Mehdi
};
enum Stat {
AverageCups, Wins
};
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
HashType<Person, int> hashRawArray[HASHSIZE];
HashMap<Person, int> wins = HashMap<Person, int>(hashRawArray, HASHSIZE);
HashMap<Person, int> avgCups = HashMap<Person, int>(hashRawArray, HASHSIZE);
HashMap<Person, int> gamesPlayed = HashMap<Person, int>(hashRawArray, HASHSIZE);
Person currPlayer = Jack;
Stat currStat = Wins;
Person findNextPlayer(Person currPlayer) {
switch (currPlayer) {
case Jack:
return Chris;
case Chris:
return Mason;
case Mason:
return Will;
case Will:
return Evan;
case Evan:
return Nick;
case Nick:
return Declan;
case Declan:
return Mehdi;
case Mehdi:
return Jack;
default:
return Jack;
}
}
String evalEnum2(Stat s) {
switch (s) {
case Wins:
return "Wins: ";
case AverageCups:
return "Average Cups: ";
default:
return "No Stat Selected";
}
}
String evalEnum(Person p) {
switch (p) {
case 0:
return "Jack";
case 1:
return "Chris";
case 2:
return "Mason";
case 3:
return "Will";
case 4:
return "Evan";
case 5:
return "Nick";
case 6:
return "Declan";
case 7:
return "Mehdi";
default:
return "err";
}
}
void setup() {
wins[0](Jack, 0);
wins[1](Chris, 0);
wins[2](Mason, 0);
wins[3](Will, 0);
wins[4](Evan, 0);
wins[5](Nick, 0);
wins[6](Declan, 0);
wins[7](Mehdi, 0);
avgCups[0](Jack, 0);
avgCups[1](Chris, 0);
avgCups[2](Mason, 0);
avgCups[3](Will, 0);
avgCups[4](Evan, 0);
avgCups[5](Nick, 0);
avgCups[6](Declan, 0);
avgCups[7](Mehdi, 0);
gamesPlayed[0](Jack, 0);
gamesPlayed[1](Chris, 0);
gamesPlayed[2](Mason, 0);
gamesPlayed[3](Will, 0);
gamesPlayed[4](Evan, 0);
gamesPlayed[5](Nick, 0);
gamesPlayed[6](Declan, 0);
gamesPlayed[7](Mehdi, 0);
Serial.begin(9600);
Serial.print("output");
irrecv.enableIRIn();
Person goat = Jack;
lcd.begin(16, 2);
lcd.print(evalEnum2(currStat));
lcd.setCursor(0, 1);
lcd.print(evalEnum(Jack));
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
Serial.println("hello");
irrecv.resume();
}
}
There are a basic examples that comes with the IR library, what happens when you try them.
Show us a good image of your ‘actual’ wiring.
The IR library has evolved, I would suggest you test with their examples to ensure your setup is correctly wired and adopt the new API for your code
Where can I find their examples? I've got the documentation open but only see version history and compatibility
If you installed the library properly (using the IDE library manager) there will be examples when you go to File, Examples, IRRemote.
Stupid question, does your remote have battery? I’d expect they come without
Hi,
No it is not?
@therealscatman have you checked the output of the IR transmitter with your phone camera?
Although it seems most new cams have IR filters and cannot see the output, but worth a try.
Tom....
![]()
I did and it had a battery and was working. I actually bought a new one today and wired it up the same way and everything seems to be working, must have just been a faulty unit!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
