关于51单片机LED矩阵流水显示时间怎么加长 怎么把0显示两秒后再 再黑屏1秒 再显示2 两秒钟.....这样流水显示0.1.23.4.5.6......
#include<reg51.h> //调用头文件
#include<intrins.h> //包含有左移 右移 延时nop
typedef unsigned int u16;//数据类型声明定义
typedef unsigned char u8;
sbit SRCLK=P3^6; // 接P3-6口 74HC595 移位寄存器时钟输入 上升沿有效
sbit RCLK=P3^5; // 接P3-5口 数据 存储送入锁存器 上升沿有效
sbit SER=P3^4; // 接P3-4口 串行数据输入 一个字节
u8 code LEDduan[][8]={{0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00}, //0
{0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00}, //1
{0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00}, //2
{0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00}, //3
{0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00}, //4
{0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00}, //5
{0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00}, //6
{0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00}, //7
{0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00}, //8
{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00}, //9
{0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00}, //P
{0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00}, //R
{0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00}, //E
{0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00}, //C
{0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00}, //H
{0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00}, //I
{0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00}, //N
{0x00,0x12,0x14,0x78,0x14,0x12,0x00,0x00}, //大
{0x00,0x08,0x12,0x01,0xFF,0x00,0x10,0x08}, //小
{0x7F,0x41,0x5D,0x55,0x5D,0x41,0x7F,0x00}, //回
{0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00}}; //中
u8 LEDwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void delay(u16 i)//定义延时函数
{
while(i--);
}
void HC595Send(u8 dat) //定义HC595函数,dat是形式参数 dat表示要输入数据
{
u8 i ;
SRCLK=0; //移位时钟清零
RCLK=0; //锁存输出清零
for(i=0;i<8;i++) //循环8次,从高位到低位 逐位输出8位SER数据
{
SER=dat>>7;
/* 将dat右移7位 赋值给SER dat数据不变 ; 例如 1001 1011 经过右移7位后
后7位全部移走 只剩之前最高位的1 ,1赋值给SER的最低位;
若下次循环,再赋值给SER的次最低位
SER输出的值
1
0
输入串行dat数据 0
1001 1011 →→→→→→ 1
1
0
1
1
*/
dat<<=1; //dat左移1位,最高位移走 最低位补0;例如dat的值1001 1011左移一位以后 dat的值是0011 0110 这是为下次移次低高位做准备 下次移0011 0110 最高位的0
SRCLK=1; //输出移位时钟信号,HC595锁存器从低到高移动一位锁存
_nop_(); // 延时一个周期
_nop_();
SRCLK=0; //移位寄存器拉低,为下次移位存储拉高准备
}
RCLK=1; //锁存已经全部移好的数据
}
void main()
{
while(1)
{
u8 i,j,k=0;
for(j=0;j<100;j++)
{
for(i=0;i<8;i++)
{
HC595Send(LEDduan[k][i]);
P0=LEDwei[i];
delay(100);
}
delay(3000);
HC595Send(0x0);
delay(1000000000000000);
k++;
if(k==21)k=0;
}
}
} |