Hi, I am using a Temu IR remote as a keyboard for a hobby project.
From time to time, the receiver seems to stop working.
Power off & reloading the sketch makes no difference.
I check the remote on a spare Uno with the same IR receiver, & it work fine.
At this point, I remember what I did the last time - unplug/re-plug the IR receiver,
& all is back to normal (for a week or so).
Thanks for replying. Project is for an X-Y table for my bench drill. Using an IR remote saves a bunch of I/O & extra hardware!
The code is +/-1200 lines! No Strings used. IR receiver connects via the CNC shield (image attached).
The receiver is connected to D12 (marked A-step on the shield) + adjacent +5/gnd.
I replaced the receiver the first time I had the problem. Of course, that fixed things!
I am using an old library (Shirriff), as I could not get things to work with the latest.
At start-up, the sketch prompts for drill up (limit switch) + OK from the remote before doing anything else.
This is when I get the problem (once in a while).
As I am busy with the sketch, I am re-compiling & down-loading several times per hour, so it's a very elusive bug!
Bits of code relative to IR:
#include <IRremote.h> //including infrared remote library V2.5.0
int IRPIN = 12; //was A.step
IRrecv IR(IRPIN);
decode_results cmd;
...
void setup() {
Serial.begin(9600);
pinMode(IRPIN, INPUT);
IR.enableIRIn();
...
void wait_IR(void) {
Serial.print("IR: ");
IR.resume();
//delay(500);
while(IR.decode(&cmd) == 0); //wait for IR
Serial.print(cmd.value, DEC);
Serial.print(F(" "));
delay(400);
IR.resume();
while(IR.decode(&cmd) != 0) IR.resume(); //wait for no IR
}
...
I have no trouble entering a command +3-digit parameter + OK, i.e goto Xnnn (if I don't type too fast!).
The delay in wait_IR() is to stop repeats.
I don't quite understand how the problem presents itself.
Can you give more details?
And some questions:
If you reload your code, it doesn't work. Right?
But if you load a simple code that, for example, lights up LED 13 when you click on IR, does it work?
When it is not working, have you measured whether there is any voltage variation at the IR sensor output?
The IR receiver seems to stop wanting to receive transmission from the remote.
I have another Uno + IR receiver (spares) for checking that it's not the remote which is at fault.
It uses the same IR code, & never fails.
I haven't yet measured the voltage from the IR receiver.
I'm beginning to suspect a bad connection on the plug on the CNC shield.
I send long sequences of codes from the remote to the project when testing (X-Y co-ordinates, tool diameter, fillet radius, drill depth, etc.), & there is never a problem
(apart from "finger trouble" & being too quick). And then, at some point (next week?), it stops until I shake up the hardware.
(as I now supect - bad connection!). I guess I'll redo the connector tomorrow.
Thanks for your time.
Regards,
Richard
P.S. Photo: it's almost ready to put on the drill, for some real testing!