#include "reg51.h"
unsigned char P1table1[]={0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,0x00};
unsigned char P1table2[]={0x80,0x00,0x40,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x04,0x00,0x02,0x00,0x01,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<16;i++)
{
P1=~P1table1[i];
delay_1ms(1000);
}
}
else if(dip_sw1 == 1)
{
for(i=0;i<16;i++)
{
P1=~P1table2[i];
delay_1ms(1000);
}
}
}
}
沒有留言:
張貼留言