unsigned char P1table1[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
unsigned char P1table2[]={0xFF,0x00};
int i;
sbit dip_sw1=P0^0;
void delay_1ms(int);
void delay_1ms(int k)
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<114;j++)
;
}
main()
{
while(1)
{
if(dip_sw1==0)
{
for(i=0;i<8;i++)
{
P1=~P1table1[i];
delay_1ms(1000);
}
}
else if(dip_sw1 == 1)
{
for(i=0;i<2;i++)
{
P1=P1table2[i];
delay_1ms(1000);
}
}
}
}
沒有留言:
張貼留言