Maker Pro
Maker Pro

38kHz TSOP read for remote on A. Uno

wingnut

Aug 9, 2012
255
Joined
Aug 9, 2012
Messages
255
Dear All

I am writing a C program on the Arduino Uno to make it into a universal remote where it can read an IR signal from some TV remote and then play this back via an IR LED.

This worked fine on a PIC690 in Mikrobasic where I used these lines...

while portA.2 = 1
wend

This worked fine to loop/wait indefinitely for the TV remote to be pressed so the signal could be copied.

The same on the Uno becomes....

while (digitalRead(2) == 1) { }

Here is the problem. Even though I have a pullup resistor of 1k5 on digital pin 2 (actually pin 4 of the Atmega328),
the above line of C does not stop/loop infinitely because, for some reason, pin2 goes to zero occasionally and does not wait for me to press the TV remote so it can copy it. I even removed the TSOP from digital pin 2 so there is no other input on that pin, and it still did not halt the program from continuing. In the setup I wrote.... pinMode(2, INPUT); to ready it for the read.

Any suggestions would be welcomed. Thanks
 
Top