单片机源程序如下:
#include <regx51.h>
#include "intrins.h"
unsigned char NixieTable[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};
void Delay1ms(unsigned int xms) //@12.000MHz
{
unsigned char i, j;
while(xms--)
{
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
}
}
void Nixie(unsigned char location,unsigned char number)
{
switch(location)
{
case 1:P2_0 = 1; P2_1 = 0; P2_2 = 0; P2_3 = 0; break;
case 2:P2_0 = 0; P2_1 = 1; P2_2 = 0; P2_3 = 0; break;
case 3:P2_0 = 0; P2_1 = 0; P2_2 = 1; P2_3 = 0; break;
case 4:P2_0 = 0; P2_1 = 0; P2_2 = 0; P2_3 = 1; break;
}
P0 = NixieTable[number];
Delay1ms(10);
}
void main()
{
while(1)
{
Nixie(1,1);
Nixie(2,2);
Nixie(3,3);
Nixie(4,4);
}
}
|