如何能让点阵显示的数字在外部中断中闪烁起来,我编写了程序,但烧录之后是瞬间闪一下,而且亮度很低,求大神帮助
d#include <AT89X52.H>
#include "74HC595.H"
sbit k1=P3^2;
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code digittab[11][8]={ //字模取模方式 阴码 逆向 逐列式 点阵显示为从下往上看
{0x00,0x00,0x3E,0x41,0x41,0x3E,0x00,0x00},/*"0",0*/{0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},/*"1",1*/{0x00,0x00,0x62,0x51,0x49,0x46,0x00,0x00},/*"2",2*/{0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00},/*"3",3*/{0x00,0x00,0x38,0x26,0x7F,0x20,0x00,0x00},/*"4",4*/{0x00,0x00,0x4F,0x49,0x49,0x31,0x00,0x00},/*"5",5*/{0x00,0x00,0x3E,0x49,0x49,0x32,0x00,0x00},/*"6",6*/{0x00,0x00,0x03,0x71,0x09,0x07,0x00,0x00},/*"7",7*/{0x00,0x00,0x36,0x49,0x49,0x36,0x00,0x00},/*"8",8*/{0x00,0x00,0x26,0x49,0x49,0x3E,0x00,0x00},/*"9",9*/{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*灭*/
};
unsigned int timecount;
unsigned char cnta;
unsigned char cntb; void delay1ms(unsigned int i)
{unsigned char j;
while(i--)
{
for(j=0;j<115;j++) //1ms基准延时程序
{
;
}
}
}
void main(void)
{
EA=1; //开放总中断
EX0=1; //允许使用外中断
IT0=0; //选择低电平来触发外中断
while(1)
{
for(cnta=0;cnta<8;cnta++)
{
Ser_IN(tab[cnta]);//8X8点阵列扫描
Ser_IN(digittab[cntb+1][cnta]);//8X8点阵行送扫描数据 +1与-1视显示而定
Par_OUT();
}
}//74HC595输出显示
} void int0(void) interrupt 0 using 0 //外中断0的中断编号为0
{
if(k1==0)
{
delay1ms(30);
if(k1==0)
{
for(cnta=0;cnta<8;cnta++)
{
Ser_IN(tab[cnta]);//8X8点阵列扫描
Ser_IN(digittab[cntb+10][cnta]);//8X8点阵行送扫描数据 +1与-1视显示而定
Par_OUT();
delay1ms(2500);
for(cnta=0;cnta<8;cnta++)
{
Ser_IN(tab[cnta]);//8X8点阵列扫描
Ser_IN(digittab[cntb+1][cnta]);//8X8点阵行送扫描数据 +1与-1视显示而定
Par_OUT();
delay1ms(2500); }
}
}
//底下部分是.H文件,主要是上面的程序如何修改,请大神给与帮助//
//Note: 74HC595驱动
// __ __
//Note: MR 主复位接电源正极, OE 使能端,输出有效接电源负极
/*--------------------------------------------*/
#ifndef __74HC595_H__
#define __74HC595_H__
/*--------------------------------------------*/
sbit SD = P1^0; //串行数据输入
sbit ST_CK = P1^1; //存储寄存器时钟输入
sbit SH_CK = P1^2; //移位寄存器时钟输入
/*--------------------------------------------*/
//数码管断码和位码的定义
//unsigned char code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00,0xff};
//0 1 2 3 4 5 6 7 8 9 a b c d e f 8 无
//unsigned char code pos[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
//1 2 3 4 5 6 7 8
/*--------------------------------------------*/
//函数声明
void Ser_IN(unsigned char Data); //串行数据输入
void Par_OUT(void); //串行数据输出
//void Ser_Par(unsigned char Data); //串行输入,并行输出
/*--------------------------------------------*/
//串行数据输入
void Ser_IN(unsigned char Data)
{
unsigned char i;
for(i = 0; i < 8; i++)
{
SH_CK = 0; //CLOCK_MAX=100MHz
SD = Data & 0x80;
Data <<= 1;
SH_CK = 1;
}
}
/*--------------------------------------------*/
//并行数据输出
void Par_OUT(void)
{
ST_CK = 0;
ST_CK = 1;
}
/*--------------------------------------------*/
//串行输入,并行输出
/*void Ser_Par(unsigned char Data)
{
Ser_IN(Data);
Par_OUT();
}
*/
/*--------------------------------------------*/
#endif
补充内容 (2018-6-29 16:41):
delay1ms(2500)就是延时,但是跑板子还是瞬间闪烁一下,而且亮度很暗,不知如何修改
我选用的是74HC595芯片连个芯片串联,并未有电阻的问题啊?
一周热门 更多>