38kHz TSOP read for remote on A. Uno

Discussion in 'Microcontrollers, Programming and IoT' started by wingnut, Jan 9, 2017.

  1. wingnut


    Aug 9, 2012
    Likes Received:
    South Africa
    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

    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
    wingnut, Jan 9, 2017
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.