最近开始玩单片机,用数据管的时候发现是阳极管,所以阴极管的消影方法就不是很适用了.
于是直接利用消影抽象方法:消去上阶段的数据来去除这阶段出现的上阶段残影.
以下是代码及消影解释:
/*
中断计时器及数据管(阳极管)消影
*/
#include <reg52.h>
sbit LATCH1 = P2^2;//段码
sbit LATCH2 = P2^3;//位码
unsigned char code LedChar[]=
{
0xC0,0xF9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e
};
unsigned char ADDNum[8]=
{
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
unsigned char flag1s = 0;
unsigned int cnt = 0;
unsigned char i = 0;
void main()
{
unsigned int sec = 0;
unsigned char k = 0;
EA |= 1;
ET0 = 1;
TMOD= 0x01;
TH0 = 0xfc;
TL0 = 0x67;
TR0 = 1;
while(1)
{
if (flag1s==1)
{
unsigned char sgn = 0;
flag1s = 0;
sec++;
if (sec/10==0)
sgn = 0;
else if (sec/100==0)
sgn &