- This topic has 1 reply, 2 voices, and was last updated 10 years, 6 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › a very basic program not working?
# include<reg51.h>
sbit a=P1^1;
sbit b=P1^2;
sbit p=P1^3;
sbit q=P1^4;
sbit r=P1^5;
sbit mot1p=P2^0;
sbit mot1n=P2^1;
sbit mot2p=P2^2;
sbit mot2n=P2^3;
void main()
{
P1=0xFF;
while(1)
{
if((p&q&r==1) && (a&b==0))
{
mot1p=1;
mot1n=0;
mot2p=1;
mot2n=0;
}
}
}
guyz this is simple program ive written where in i connect five switches from p1.1 to p1.5 with logic 00111 but when i check the o/p at p2.0 to p2.3 it gives all logic 1s after each reset when it should have been 1010 acc to the program.im using keil ide and at89s52 as muc
please people i need your help
thanks in advance
Hi,
I understand that you’ve connected switches on port 1. Then why are you trying to write into the same port as ‘ P1=0xFF ‘, those pin should be made input and you are supposed to read those pins.