51单片机LED1616点阵滚动显示C程序.doc

上传人:hw****26 文档编号:3549684 上传时间:2019-06-04 格式:DOC 页数:35 大小:349KB
下载 相关 举报
51单片机LED1616点阵滚动显示C程序.doc_第1页
第1页 / 共35页
51单片机LED1616点阵滚动显示C程序.doc_第2页
第2页 / 共35页
51单片机LED1616点阵滚动显示C程序.doc_第3页
第3页 / 共35页
51单片机LED1616点阵滚动显示C程序.doc_第4页
第4页 / 共35页
51单片机LED1616点阵滚动显示C程序.doc_第5页
第5页 / 共35页
点击查看更多>>
资源描述

1、51单片机 LED16*16点阵滚动显示 C 程序发布时间:2009-11-23 21:07信息来源:实践教学网 发布者:admin 点击: 次51单片机 LED16*16点阵滚动显示 C 程序(附有电路图) 。/*功能:LED16*16点阵滚动显示说明:74LS164 用作发送数据,P0,P2口用来列选看本程序最好的工具最好旁边有标号和语法着色,推荐 keil 或 UltraEdit懒人提示:要改成自己所要的显示内容,要怎么改?1.要改显示内容改第2392行代码,还有第119行代码,具体改法见下面注释2.要改滚动速度改第102行代码*/*头文件*/#include#include/*宏定义*

2、/#define uchar unsigned char#define uint unsigned int/*函数声明*/void delay();/*全局变量*/uint lie; /列选标志/* 字模: 反显,纵向取模,开头和结尾均加入32个0xFF,用于改善屏滚动显示时循环的连贯性 */* 杭州市公交公司 K316路,开往武林广场,发车时间20:30,欢迎大家乘坐! - * 宋体, 12 */* 当前所选字体下一个汉字对应的点阵为: 宽度 x 高度=496x16, 调整后为: 496x16 */uchar code text1056= /这里的数据为你要显示的内容的数据量+64(前后各3

3、2个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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E,0xFB,0xFD,0xFB,0xFB,0xFB,0xF7,0xFB,0xCF,0xFA,0x3F,0x01,0xFF,0xFA,0x7F,0xFB,0x9F,0xFB,0xEF,0xFB,0xF3,0xFB,0xF9,0xFB,0xFC,0xFB,0xFD,0xFF,0xFF,0

18、xFF,0xFF,0xE7,0x6B,0xDF,0x6B,0xD7,0x57,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,0

19、xEE,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,0

20、xFF,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; /初始化

21、串口为工作方式0(同步通信方式,TxD 输出同步脉冲)lie=0x7fff; /列选标志初始化while(1) /重复循环显示for(j=0;j1024)/这个数据为你的字模数组的大小-32,我的是1056-32=1024m=0;/*延时子程序*/void delay()uint n;for(n=0;n#include#include#define uint unsigned int#define uchar unsigned char#define PA 0x7cff /PA 口#define PB 0x7dff /PB 口#define con 0x7fff /控制字sbit A8=P20

22、; /地址线 A0 sbit A9=P21; /地址线 A1sbit cs=P27; /片选sbit wr=P36; /读端口uint temp;uchar tplsb,tpmsb; / 温度值低位、高位字节sbit date=P12; /数据通信线uchar code tableshi=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;/数码管段选 十位uchar code tablege=0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef;/数码管段选 个位 带小数点/uchar code t

23、ablewei=0xfe,0xfd,0xfb,0xf7,0xef,0xdf;/数码管位选void delay(uchar i)uchar j,k;for(j=i;j0;j-)for(k=125;k0;k-);void init()uint i;date=1;delay(1);date = 0;i = 100; /拉低约900uswhile (i0) i-; date= 1; / 产生上升沿i = 4;while (i0) i-;void wait()uint i;while(date);while(date); / 检测到应答脉冲i = 4;while (i0) i-;bit readbit(

24、)uint i;bit b;date = 0;i+;date = 1;i+;i+; / 延时15us 以上,读时隙下降沿后15us,DS18B20输出数据才有效b = date;i = 8;while(i0) i-;return (b);uchar readbyte()uchar i,j,b;b = 0;for (i=1;i1);/读出的数据最低位在最前面,这样刚好一个字节在 DATE 里return(b);void writebyte(uchar b)/uint i;uchar j;bit btmp;for(j=1;j1; / 取下一位(由低位向高位)if (btmp) / 写1date =

25、 0;i+;i+; / 延时,使得15us 以内拉高date = 1;i = 8;while(i0) i-; / 整个写1时隙不低于60uselse / 写0date = 0; i = 8;while(i0) i-; / 保持低在60us 到120us 之间date = 1;i+;i+;void convert() init(); / 产生复位脉冲,初始化 DS18B20wait(); / 等待 DS18B20给出应答脉冲delay(1); / 延时writebyte(0xcc); / 跳过 rom 命令writebyte(0x44); / convert T 命令uint readtemp(

26、) float tt;init(); / 产生复位脉冲,初始化 DS18B20wait(); / 等待 DS18B20给出应答脉冲delay(1); / 延时writebyte(0xcc); / 跳过 rom 命令writebyte(0xbe); / read scratchpad 读暂存器命令tplsb=readbyte(); / 温度值低位字节(其中低4位为二进制的“小数“部分)tpmsb=readbyte(); / 温度值高位字节(其中高5位为符号位)temp=tpmsb;temp=8; /合成一个字 temp=temp|tplsb; tt=temp*0.0625;temp=tt*10+0.5;return temp; void display(uint temp) uchar A1,A2,A3;A1=temp/100;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 精品笔记

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。