We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have use following code for 8051 by NXP(p89v51rd2)
#include<reg51.h> #define p2 P2 sfr P1=0x90; sbit led1=p2^0; sbit s=P1^0; void main() { s=1; while(1) { if(s==0) { led1=1; } else { led1=0; } } }
I have connected led on port 2 (pin no. 0) circuit of sensor is here elecrom.wordpress.com/.../
this sensor on black background generate 0 to 1.5 Volt
when i connect ground to port 1 via 1k led glow but when i give output from sensor (IR sensor) output volt of sensor increase to 5V. Is there something wrong with program?
yes when I have the sensor alone, the output is 0 to 1.5 V, but when you connect it to a port pin the output is 5V
what is solution?
get the datasheet fot the sensor, it is 99.9% likely open collector output, in which case what you see is what you should expect.
Erik