当前位置:网站首页>Simple operation of nixie tube (keil5)

Simple operation of nixie tube (keil5)

2022-07-05 07:18:00 After reading thousands of books, you can pick them up and put

Every bit of the nixie tube starts from 0 Light to f Jump to the next one , Then all the bits start from 0 Light to f

#include <STC15F2K60S2.H>
#include <intrins.h>
int i,j;
unsigned char code num[16]={
    0xc0,0xcf,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98,0x88,0x80,0xc6,0xc0,0x86,0x8e};//0123456789abcd
/*************************************************/
void initsystem(unsigned char i)
{
    
	switch(i)
	{
    
		case 4:
			P2=0X8f&(P2|0xe0);// open y4 Latch 
		break;
		case 5:
			P2=0xbf&(P2|0xe0);// open y5 Latch 
		break;
		case 6:
			P2=0xdf&(P2|0xe0);// open y6 Latch 
		break;
		case 7:
			P2=0xff&(P2|0xe0);// open y7 Latch 
		break;
		case 0:
			P2=0x1f&(P2|0xe0);// Close the latch 
		break;
	}
}
/*******************************************/
void Delay100ms()		//@11.0592MHz
{
    
	unsigned char i, j, k;

	_nop_();
	_nop_();
	i = 5;
	j = 52;
	k = 195;
	do
	{
    
		do
		{
    
			while (--k);
		} while (--j);
	} while (--i);
}
/*****************************************************************/
void SMG_change()// Each from 0 Light to f, And then all from o Light to f.
{
    
	for(i=0;i<8;i++)
	{
    
	initsystem(6);
	P0=0x01<<i;
		for(j=0;j<16;j++)
		{
    
		initsystem(7);
		P0=num[j];
		Delay100ms();
		Delay100ms();
		Delay100ms();
		}
	}
		initsystem(6);
		P0=0xff;
		for(j=0;j<16;j++)
		{
    
		initsystem(7);
		P0=num[j];
		Delay100ms();
		Delay100ms();
		Delay100ms();
		}
}
/*********************************************************************/
void main()
{
    
	initsystem(4);// open y4
	P0=0xff;// Turn off the lights 
	initsystem(0);// Turn off y4
	initsystem(5);// open y5
	P0=0x00;// Turn off the relay buzzer 
	initsystem(0);// Turn off y5
	while(1)
	{
    
		SMG_change();
	}
}
原网站

版权声明
本文为[After reading thousands of books, you can pick them up and put ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140558148739.html