动态数码管
#include<reg52.h>
#define Nixie_PORT P0
sbit K3=P2^4;
sbit K2=P2^3;
sbit K1=P2^2;
char code Nixie_data[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07};
void delay_ms(unsigned int ms)
{
unsigned int i,j;
for(i=ms;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
unsigned char i;
while(1)
{
for(i=0;i<8;i++)
{
switch(i)
{
case 0:K3=1;K2=1;K1=1;break;
case 1:K3=1;K2=1;K1=0;break;
case 2:K3=1;K2=0;K1=1;break;
case 3:K3=1;K2=0;K1=0;break;
case 4:K3=0;K2=1;K1=1;break;
case 5:K3=0;K2=1;K1=0;break;
case 6:K3=0;K2=0;K1=1;break;
case 7:K3=0;K2=0;K1=0;break;
}
Nixie_PORT=Nixie_data[i];
delay_ms(1);
Nixie_PORT=0x00;
}
}
}
|