keil + proteus 点亮数码管

       点亮数码管的思路很巧妙, 运用了视觉停留和欺骗 的原理。 这里点非常巧妙, 你想想, 多个数码管, 可是共线路哦!


        先看看数码管:

keil + proteus 点亮数码管_第1张图片

       看程序keil c:

#include

unsigned char LED[10] = {63, 48, 91, 79, 102, 109, 125, 7, 127, 111};
unsigned char a[8] = {1, 2, 4, 8, 16, 32, 64, 128};  

void delay(int n)
{
	int i = 0;
	int j = 0;
	for(i = n; i > 0; i--)
	{
		for(j = 110; j > 0; j--)
		{
			;
		}
	}
}

void main() 
{
	int x[] = {1, 4, 7, 2, 5, 8};
	int i = 0;
	int j = 0;

	for(j = 0; j < 6; j++)
	{
		P1 = 255 - a[j];
		P2 = LED[x[j]];
		delay(10);		// 必要
	}
}
       结果:

keil + proteus 点亮数码管_第2张图片


你可能感兴趣的:(S1:,C/C++,s2:,Linux杂项,s2:,嵌入式,s4:,计算机组成,S5:,IT零碎,s6:,物理/通信)