Hear the interfacing of general input device with P89V51RD2 controller
when ever the input enabled that time the output connected to the port 1 of MSB will be high.
Code:
#include <reg51.h>
//sbit switch1 = P1^1;
void delay()
{
unsigned int i,j;
for(i=0;i<=256;i++)
{
for(j=0;j<=10000;j++);
}
}
void main(void)
{
//P1 = 0xfe;
delay();
while(1)
{
if(P1==0xfe)
{
P1 = 0xf0;
delay();
}
}
}
//sbit switch1 = P1^1;
void delay()
{
unsigned int i,j;
for(i=0;i<=256;i++)
{
for(j=0;j<=10000;j++);
}
}
void main(void)
{
//P1 = 0xfe;
delay();
while(1)
{
if(P1==0xfe)
{
P1 = 0xf0;
delay();
}
}
}
Comments
Post a Comment