LED16*16点阵滚动显示程序

2018-01-14 20:20:24编辑:什么鱼 关键字:LED  16*16点阵  滚动显示

/****************************************************************** 
功能:LED16*16点阵滚动显示 
说明:74LS164用作发送数据,P0,P2口用来列选 
看本程序最好的工具最好旁边有标号和语法着色,推荐keil或UltraEdit 
懒人提示:要改成自己所要的显示内容,要怎么改? 
1.要改显示内容改第23~92行代码,还有第119行代码,具体改法见下面注释 

 

2.要改滚动速度改第102行代码 
*******************************************************************/ 
/*头文件*/ 
#include 
#include 
/*宏定义*/ 
#define uchar unsigned char 
#define uint  unsigned int 
/*函数声明*/ 
void delay(); 
/*全局变量*/ 
uint lie; //列选标志 

/** 字模:反显,纵向取模,开头和结尾均加入32个0xFF,用于改善屏滚动显示时循环的连贯性   **/ 
/** 杭州市公交公司K316路,开往武林广场,发车时间20:30,欢迎大家乘坐!  --  **  宋体, 12  **/ 
/** 当前所选字体下一个汉字对应的点阵为:  宽度x高度=496x16,  调整后为: 496x16          **/ 
uchar code text[1056]={   //这里的数据为你要显示的内容的数据量+64(前后各32个0xff) 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
//改显示内容以上两行别改 
0xEF,0xDF,0xEF,0x3F,0xE8,0xFF,0x00,0x00,0xED,0xFF,0xFE,0xFD,0xEF,0xF3,0xEC,0x0F, 
0x6D,0xFF,0x8D,0xFF,0xED,0xFF,0xEC,0x03,0xEF,0xFD,0xEF,0xFD,0xEF,0xE1,0xFF,0xFF, 
0xFF,0x7F,0xF8,0xFE,0xFF,0xF9,0xFF,0xE7,0x00,0x1F,0xFB,0xFF,0xFC,0xFF,0xFF,0xFF, 
0x80,0x01,0xF7,0xFF,0xF9,0xFF,0xFE,0x7F,0xFF,0xFF,0x00,0x00,0xFF,0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0xD6,0xD7,0xD6,0xAD,0x54,0x6E,0x92,0xDD, 
0xD7,0x03,0xD7,0x9F,0xD6,0x6F,0xDF,0x6F,0xD7,0xF7,0xCF,0xF3,0xDF,0xF7,0xFF,0xFF, 
0xEF,0xBB,0xEB,0xBB,0xAB,0x77,0xAB,0x77,0xA0,0x2F,0xAF,0xCF,0xAF,0x9F,0x80,0x01, 
0xAF,0xBF,0x6F,0xDF,0x60,0x4F,0x6D,0x67,0x6B,0x73,0xCB,0x77,0xEE,0x7F,0xFF,0xFF, 
0xFF,0x7D,0xFE,0xFD,0xF9,0xDD,0xC7,0xDD,0xFB,0xDD,0xFC,0xDD,0xFF,0xDD,0x00,0x01, 
0xFF,0x5D,0xFE,0xDD,0xFD,0xDD,0xC3,0xDD,0xFD,0xDD,0xFE,0xFD,0xFF,0xFD,0xFF,0xFF, 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x05,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
//改显示内容以下两行别改 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF 
}; 

/*主函数*/ 
void main() 
{uchar i,j; 
 uint m=0;//m是从字模数组里向后取数据时的计数器,用以改变显示文字的内容,及滚动显示效果 
 SCON=0;  //初始化串口为工作方式0(同步通信方式,TxD输出同步脉冲) 
 lie=0x7fff; //列选标志初始化 
 while(1) //重复循环显示 
 {for(j=0;j<10;j++) //j用来控制屏上1帧显示内容停留的时间,即用来控制滚动速度 
 { for(i=1;i<=31;i+=2) 
    {P0=0xff;//先关显示,以免164内数据移动过程中在屏上产生不良影响,大家可以把这两句去掉比较下显示效果 
     P2=0xff; 
     SBUF=text[i+m];//从串口发送字模数据(为什么要先发后一个数据,看下电路应该会明白吧:) 
     while(TI==0);  //等待发送完毕 
     TI=0; 
     SBUF=text[i+m-1];//从串口发送数据,补全整一列数据 
     while(TI==0); 
     TI=0; 
  P0=lie%256;//选中要显示的那列,同时等于打开了那列的显示 
     P2=lie/256; 
     delay(); //延时,等待一段时间,让这列显示的内容在人眼内产生“视觉暂留”现象,略知生理的人应该都知道吧。 
  lie=_iror_(lie,1); //列选标志移位,准备用来选中下一列 
      } 
  }//返回显示下一列,直到16列都显示完成 
  m+=2;//显示内容向后移一列 
  if(m>1024)//这个数据为你的字模数组的大小-32,我的是1056-32=1024 
  m=0; 
    } 
 } 

/*延时子程序*/ 
void delay() 
{uint n; 
 for(n=0;n<90;n++) 
   {;} 
 } 


关键字:LED  16*16点阵  滚动显示

来源: eefocus 引用地址:http://www.eeworld.com.cn/mcu/article_2018011437346.html
本网站转载的所有的文章、图片、音频视频文件等资料的版权归版权所有人所有,本站采用的非本站原创文章及图片等内容无法一一联系确认版权者。如果本网所选内容的文章作者及编辑认为其作品不宜公开自由传播,或不应无偿使用,请及时通过电子邮件或电话通知我们,以迅速采取适当措施,避免给双方造成不必要的经济损失。

上一篇:89C51串并转换驱动数码管示例程序
下一篇:PDIUSBD12 USB 驱动程序

关注eeworld公众号 快捷获取更多信息
关注eeworld公众号
快捷获取更多信息
关注eeworld服务号 享受更多官方福利
关注eeworld服务号
享受更多官方福利

推荐阅读

51单片机实现LED流水灯(数组方式和位运算方式)

/* 名称:51单片机实现LED流水灯(数组方式和位运算方式)说明:今天又重新开始系统的学习51了,LED就算个开端吧。 要注意两点: 1、sfr和sbit是C语言扩展出来的关键字。其中sfr用于对特殊功能寄存器进行声明,sbit用于对某些特殊功能寄存器的某位进行声明。这里和宏定义很相似,但是不能用宏定义进行替换,对于前者是因为51单片机的寄存器存在于内部空间0x80-0xFF,这空间属于直接寻址,51特殊功能寄存只能直接寻址,不能间接寻址。如果用宏定义的话,在翻译成汇编时就会认为是通过总线访问对应的外部地址了。对于后者,sbit是定义一个标志位,也叫位变量。而类似于#define key1 P3
发表于 2018-07-21 13:08:22

S3C2440学习之GPIO按键控制LED灯

/* 名称:S3C2440学习之GPIO按键控制LED灯 说明:这是实验2440GPIO的输入功能。基本的流程和51单片机开发的差不多。都是对GPIO端口寄存器的控制不同的是,51单片机可以直接对进行位控制,而2440中GPIO只能对32位的寄存器进行写入或者读出。这样的话,对于有些逻辑操作要稍微复杂点。还有个不同的是,无论是STM32还是51在进行IO按键输入的时候,都需要进行按键消抖,在这里却没又体现出来按键消抖,这是为什么呢?据我了解是这样,在进行51和STM32实验的时候,按键控制的是数码管(数字增加,降低),所以按键的机械抖动会给数码管数字的变化带来显著的影响。在这里是按键控制led灯的亮和灭
发表于 2018-07-21 11:58:46

STM32定时器之控制LED灯循环显示

/* 名称:STM32定时器之控制LED灯循环显示 说明:对于STM32来说,其定时器要比C51的定时器要多,功能也更复杂。就数目来说来说,STM32的定时器可以分为基本定时器,通用定时器和高级定时器(还包括Systick、看门口定时器和窗口定时器)。就STM32F103,一般来说,它有2个高级定时器TIM1和TIM8、4个通用定时器TIM2/3/4/5、2个基本定时器TIM6和TIM7。而C51一般只有几个定时器。就功能来说, STM32中: 对于基本定时器,其功能就是和C51差不多,只有定时功能。 对于通用定时器,它的功能有定时、输出比较、输入捕获。虽然目前,我也不知道后面两个
发表于 2018-07-21 11:56:24

STM32之LED按键中断

****************************************************************************************************************************************前言:本文主要是通过按键中断,实现当按下按键时,LED灯灭,释放按键时,LED灯亮。(不过我设置LED的起始状态为亮,也就是上电就点亮了LED灯。)下面看main.c#include "stm32f10x.h"#include "led.h"#include "exti.h"  int main(void) {     init_led_gpio();  turn_led(LED1,ON);    /*exti line
发表于 2018-07-21 11:48:43

ARM裸机程序开发——按键控制LED灯

这几天将TQ2440上的IO控制引脚学习了一下,了解了一下关于引脚的一些寄存器的配置,熟悉了一下写ARM裸机程序的流程,写一下自己学到的东西。★程序启动初始化◇关闭看门狗有一个专门的寄存器来控制看门狗,看门狗的作用就是在一定的时间内会重新启动系统,这里我们只是写一个简单的逻辑程序用不到看门狗 ,将其关掉。设置WTCON寄存器,将其第5位置0,就可以禁用看门狗◇设置栈指针C语言中设置的变量,以及调用的函数等信息都会被存放在栈中,因此栈指针必须要设置◇调用main函数main函数中设置了关于IO寄存器的一些设置操作★TQ2440硬件相关硬件主要涉及到LED灯与GPIO,按键与GPIO之间的连接◇LED灯硬件   
发表于 2018-07-21 11:48:01

STM32实战1:按键点亮LED小灯

理论知识已经学习完成,之后我们进入实战篇,在实战的学习中,我完成了第一个项目,用按键点亮了led灯下面是我的程序led主程序#include "sys.h"#include "led.h"void LED_Init(void){GPIO_InitTypeDef GPIO_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC , ENABLE);//初始化PCIO时钟GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;GPIO_InitStructure.GPIO_Speed
发表于 2018-07-21 11:17:40

小广播

何立民专栏

单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

电子工程世界版权所有 京ICP证060456号 京ICP备10001474号 电信业务审批[2006]字第258号函 京公海网安备110108001534 Copyright © 2005-2018 EEWORLD.com.cn, Inc. All rights reserved