fantabulous68
Member
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.
i want it to go on when an object is near the proximity circuit.
i want it to go off when there is no object near.
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.
i want it to go on when an object is near the proximity circuit.
i want it to go off when there is no object near.