reading output of IR receiver with pic16f690 micrcontroller

Thread Starter


Joined Nov 3, 2007
reading output of IR receiver with pic16f690 micrcontroller

im designing an infrared proximity detector for my project. I am a new user to the pic microcontroller.

I am programming in C.

i have an infrared receiver IC TSOP48.
the output of the infrared ic is active low. and can be directly demodulated by a microcontroller.

the output is on the 1st pin of the receiver module.

hardware connections:

1)pin 1 of receiver IC connected to RC2
2)in RC3 has a LED connected to it going to ground.

1)i want to feed this active low signal from the receiver IC to pin RC2 of the microcontroller when

detection occurs.

2)only when the receiver IC detects an object is near, then it will be active low.
So i want to read this pin RC2 to check if it is low.

3)now only when it is active low i want a LED connected to RC3 to light up.

4)if the module does not detect any object then i want the led to be off.

here is my code:
#include <pic.h>
#include "pic.h"
#include "delay.h"
#include "math.h"
#include <stdio.h>
#include <stdlib.h>

void main(void)

TRISC=0X04; //making pin RC2 input

if(RC2==0) //if receiver detects something then output is active low
{PORTC=0x08;} //light up led connected to RC3 if detect object else
{PORTC=0x00;} //dont light led if no detection

please assist me. i dont know why the led is always on after i program the chip and put it into the

proximity circuit.

iwant it to go on when an object is near the proximity circuit.

i want it to go off when there is no object near.


Joined Oct 14, 2005
There are no forever loop in your program. So, once the main program ran, it exited.

I don't know whether this happened when you copied your listing to this forum or not, but there is no corresponding else for the if statement.