Microcontroller › 8051 › interfacing ir sensor with 8051 › hi dude i already uploaded a
hi dude
i already uploaded a link that discribes the working of IR sensor
if you are using 8051 micro controller
to diclare the pin as input tha last thing written to the port must be “1”
if you want to make all pins of port1 as in put you need to write P1=0xff;
the sensor you showed in the link may not work properly.use the comparator circuit as shown in the following link which i already posted in previous post
the logic will be as follows
#include<reg51.h>
void main()
{
P1=0xff ; // all pins of port1 are diclared as in put
//asume that the sensor is connected to pin P0.0
// assume sensor gives high on detecting an object
while(1)
{
if((P1 & 0x01)==0x01) // bit masking to check for only P0.0
P2=0xff; // switches on the LED connected to port2 if the sensor dectects an object
else
P2=0x00;// LED off
}
}