# include <reg52.h>
typedef unsigned char uint8;
sbit S = P1^6;//74HC164的DSA引脚
sbit CP = P1^5;//74HC164的CP引脚
sbit yiw = P1^2;//数码管第一位
sbit erw = P1^4;//数码管第二位
sbit sanw= P1^3;//数码管第三位
sbit siw = P1^7;//数码管第四位
main()
{
uint8 i ;
uint8 a = 0;
while(1)
{
uint8 duanma = 0xC0;
for(i = 0; i < 8; i++)
{
S = duanma & 0x80;
CP = 0;
CP = 1;
duanma <<=1;
}
switch(a)
{
case 0: yiw = 0;a++;break;
case 1: erw = 0;a++;break;
case 2: sanw = 0;a++;break;
case 3: siw = 0;a=0;break;
default:break;
}
}
return 0 ;
} |