📄 用1602液晶写的动画_永远的月饼_新浪博客.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0052)http://blog.sina.com.cn/s/blog_4a9bee5a0100a80n.html -->
<HTML
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>用1602液晶写的动画_永远的月饼_新浪博客</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<META
content="IT'S MY WORLD!,永远的月饼,#include<at89x52.h>#defineucharunsignedchar#defineuintunsignedint#defineDataPortP2#defineBusy0x80ucharXpos,Ypos;sbitRS=P1^2;sbitRW=P1^1;sbitE=P1^0;//charcodew[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};charcodes[9][8]={{0x0E,0x0E,0x04,0x0E,0x15,0x04,0x04,0x04},{0x0E,0x0E,0x04,0x0E,0x15,0x06,0x05,0x05},{0x0E,0x0E,0x04,0x0E,0x15,0x04,0x0A,0x11},{0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00},{0x00,"
name=description>
<META content="IT'S MY WORLD!,永远的月饼,51单片机" name=keywords>
<SCRIPT>
var scope = {
$uid : "1251733082",
$PRODUCT_NAME : "blog",
$pageid : "article",
$key : "abb317780ea095b0a5539e3384300b87",
$sort_id : "117",
$loadconf : true,
$flag2008 : "0",
$articleid : "4a9bee5a0100a80n" ,
$isCommentAllow : "1"
};
var $encrypt_code = "9032b3559fca8fdfa365e2433a491c42";
var config = {"common":{"t":"8_32","head":{"tiled":"default","align_h":"center","align_v":"top","height":"100","usepic":3},"bg":{"currpic":"4a9bee5a44bbe0befefcf","usepic":3,"tiled":"default","align_h":"right","align_v":"top"},"r":0,"pageset":0,"invitationset":0},"private":{"cms":0,"blogsize":0,"ad":0,"sms":0,"adver":0},"component":{"c1":[901,1007,1005,1006,1004,1,1001,2,3,1003,8,9,12,17],"c2":[],"x":2},"product":{"c":21,"j":15}};
var fav = {"4a9bee5a0100a80n":"b6324930e8cef0fc1774129cf5bcd91b"} ;
</SCRIPT>
<STYLE>.MASS4c4cdcd9c7ad {
DISPLAY: none
}
</STYLE>
<SCRIPT src="用1602液晶写的动画_永远的月饼_新浪博客.files/boot.js"
type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>loadCss();</SCRIPT>
<SCRIPT src="用1602液晶写的动画_永远的月饼_新浪博客.files/platform_tray.compressed.js"></SCRIPT>
<LINK href="用1602液晶写的动画_永远的月饼_新浪博客.files/im.css" type=text/css rel=stylesheet><!--# block name="blk737369" --><!--# endblock --><!--#include file="/hits?act=4&aid=${aid}" stub="blk737369" -->
<META content="MSHTML 6.00.2900.3527" name=GENERATOR></HEAD>
<BODY>
<DIV id=sinatopbar>
<SCRIPT type=text/javascript>
<!--
document.write(SinaSysTray.getHTML());
//-->
</SCRIPT>
</DIV>
<SCRIPT type=text/javascript>
<!--
SinaSysTray.base_init({
"type" : scope.$PRODUCT_NAME || "",
"uid" : $UID || "0"
});
//-->
</SCRIPT>
<DIV class=wrapper>
<DIV class=headpic100 id=headpic100>
<DIV class=headpic950 id=headPic950>
<DIV class=toppicflash id=toppicflash></DIV>
<DIV class=ntoptitle id=ntoptitle>
<DIV class=ntopns id=blogTitle>
<DIV class=ntitname id=blogname><A
href="http://blog.sina.com.cn/ckt1010">IT'S MY WORLD!</A> </DIV>
<DIV class=ntitsite>http://blog.sina.com.cn/ckt1010<A class=CP_a_fuc
id=SubscribeNewRss onclick="return false;"
href="http://blog.sina.com.cn/s/blog_4a9bee5a0100a80n.html#">[<CITE>订阅</CITE>]</A></DIV></DIV></DIV></DIV>
<DIV class=termenubg></DIV>
<DIV class=termenu>
<DIV class=termenuc id=clone_template>
<DIV class=termenutag>
<DIV class=user>
<DIV class=userhead><A href="http://blog.sina.com.cn/ckt1010"><IMG
src="用1602液晶写的动画_永远的月饼_新浪博客.files/50.jpg"></A></DIV>
<DIV class=username><A style="CURSOR: hand"
href="http://blog.sina.com.cn/ckt1010"><SPAN id=nav_name></SPAN></A></DIV></DIV>
<DIV class=promenu>
<LI class=on><SPAN id=nav_blog><A
href="http://blog.sina.com.cn/ckt1010">博客</A></SPAN>
<LI><SPAN id=nav_photo><A
href="http://photo.blog.sina.com.cn/ckt1010">相册</A></SPAN>
<LI><SPAN id=nav_music><A
href="http://music.sina.com.cn/m/1251733082">音乐</A></SPAN>
<LI><SPAN id=nav_vblog><A
href="http://you.video.sina.com.cn/ckt1010">播客</A></SPAN>
<LI><SPAN id=nav_tiezi><A
href="http://profile.blog.sina.com.cn/ckt1010">个人中心</A></SPAN> <!-- <li><span id="nav_quanzi"><a href="http://q.sina.com.cn/m/ckt1010">圈子</a></span></li>--></LI></DIV></DIV>
<DIV class=termenutxt>
<DIV class=tmtcen>
<DIV class=floatLeft><SPAN><A
href="http://blog.sina.com.cn/ckt1010">首页</A></SPAN><SPAN
class=linesp></SPAN><SPAN><A
href="http://blog.sina.com.cn/s/articlelist_1251733082_0_1.html">博文</A></SPAN><SPAN
class=linesp></SPAN><SPAN><A
href="http://blog.sina.com.cn/s/favourites_1251733082_1.html">收藏</A></SPAN><SPAN
class=linesp></SPAN><SPAN><A
href="http://profile.blog.sina.com.cn/circle.php?uid=1251733082&page=1&type=3">博客圈</A></SPAN><!--<span > <a href="http://blog.sina.com.cn/lm/rank/index.html" target="_blank">排行榜</a></span>--></DIV>
<DIV class=floatRight></DIV></DIV></DIV></DIV></DIV></DIV>
<DIV class=contentLayout>
<DIV class="column_2 floatLeft">
<DIV class="components730 SinaAd_hide" id=advertise_top></DIV>
<DIV class=components730>
<DIV class=component>
<DIV class=componentBar><SPAN class="floatRight articleFontSize"
id=articleFontManage>字体大小:<A onclick="changeFontSize(2);return false;"
href="http://blog.sina.com.cn/s/">大</A><B>中</B><A
onclick="changeFontSize(0);return false;"
href="http://blog.sina.com.cn/s/">小</A></SPAN> <SPAN class=title>正文</SPAN>
</DIV>
<DIV class="componentContent article">
<DIV class=comconblog>
<DIV class=articleTitle>
<DIV style="DISPLAY: inline"><B id=t_4a9bee5a0100a80n>用1602液晶写的动画</B><SPAN
class=time>(2008-07-11 21:15:12)</SPAN></DIV></DIV>
<DIV class=articleTag>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<SCRIPT>var $tag='51单片机';var $tag_code='641caa0b405421f3d8ba3bedf16af668';</SCRIPT>
标签:<A class=tag
href="http://uni.sina.com.cn/c.php?t=blog&k=51%B5%A5%C6%AC%BB%FA&ts=bpost&stype=tag"
target=_blank>51单片机</A><WBR> </TD>
<TD vAlign=top align=right width=250></TD></TR></TBODY></TABLE></DIV>
<DIV class=articleContent id=articleBody>
<P>#include<at89x52.h><BR>#define uchar unsigned char<BR>#define uint
unsigned int<BR>#define DataPort P2 <WBR><BR>#define Busy 0x80<BR>uchar
Xpos,Ypos;<BR>sbit RS=P1^2;<BR>sbit RW=P1^1;<BR>sbit E=P1^0;<BR>//char code
w[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};<BR>char <WBR> code
s[9][8]={ <WBR>
{0x0E,0x0E,0x04,0x0E,0x15,0x04,0x04,0x04}, <WBR><BR>{0x0E,0x0E,0x04,0x0E,0x15,0x06,0x05,0x05},<BR>{0x0E,0x0E,0x04,0x0E,0x15,0x04,0x0A,0x11},<BR>{0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00},<BR>{0x00,0x00,0x04,0x0E,0x04,0x00,0x00,0x00},<BR>{0x00,0x04,0x0E,0x1F,0x0E,0x04,0x00,0x00},<BR>{0x04,0x0E,0x1F,0x1F,0x1F,0x0E,0x04,0x00},<BR>{0x00,0x1F,0x0A,0x1F,0x0A,0x0A,0x12,0x00},<BR>{0x00,0x0A,0x1F,0x1F,0x0E,0x04,0x00,0x00}};<BR>char
code
e[]={0,0x08,0x04,0x0c,0x02,0x0a,0x06,0x0e,0x01,0x09,0x05,0x0d,0x03,0x0b,0x07,0x0f,0x00};<BR>void
fz(uchar a)//我自己写的反置函数,因为我接P2口的时候接反了....<BR>{<BR>uchar
c,b;<BR> <WBR> <WBR> b=a%0x10;<BR> <WBR> <WBR>
c=a/0x10;<BR> <WBR> DataPort=e[b]*0x10+e[c];<BR>}<BR>void delay(unsigned
int i) <WBR> <WBR> <WBR> <WBR> <WBR> {<BR>unsigned int
j;<BR>for(;i>0;i--) <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR><BR>for(j=0;j<125;j++)<BR>{;}<BR>}<BR>void
CheckBusy(void)<BR> <WBR> {<BR> <WBR>DataPort=0xff;<BR> <WBR>
RS=0; <WBR> <WBR> <WBR> <WBR> <WBR><BR> <WBR>
RW=1; <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR><BR>delay(1);<BR> <WBR>
E=1;<BR>delay(1);<BR> <WBR>fz(DataPort);<BR>while(DataPort&Busy);<BR> <WBR>
E=0; <WBR>
<WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR><BR> <WBR> <WBR>
}<BR> <WBR>void Write_com(uchar com,uchar
AttribC)<BR> <WBR>{<BR> <WBR>if(AttribC)<BR> <WBR>CheckBusy();<BR> <WBR>RS=0;<BR> <WBR>RW=0;<BR>delay(1);<BR>fz(com);<BR>delay(1);<BR> <WBR>E=1;<BR>delay(1);<BR> <WBR>E=0;<BR> <WBR>}<BR> <WBR>void
Write_data(uchar
date)<BR> <WBR>{<BR>RS=1;<BR> <WBR>RW=0;<BR>delay(1);<BR>fz(date);<BR>delay(1);<BR> <WBR>E=1;<BR>delay(1);<BR> <WBR>E=0;<BR> <WBR>}<BR>void
LcdPosCG(uchar Xpos)<BR>{<BR> <WBR> uchar tmp;<BR> <WBR>
tmp=Xpos;<BR> <WBR> tmp|=0x40;<BR> <WBR> Write_com(tmp,1);<BR>}</P>
<P>void LcdPos(uchar Xpos,uchar Ypos)<BR>{<BR> <WBR> uchar
tmp;<BR> <WBR> Xpos&=0x0f;<BR> <WBR>
Ypos&=0x01;<BR> <WBR> tmp=Xpos;<BR> <WBR>
if(Ypos==1)<BR> <WBR> tmp|=0xc0;<BR> <WBR>
tmp|=0x80;<BR> <WBR>Write_com(tmp,0);</P>
<P>}</P>
<P>void WriteChar(uchar XposCG,char
c)<BR>{ <WBR> <WBR><BR>LcdPosCG(XposCG);<BR> <WBR>Write_data(c);<BR> <WBR>
<WBR>}<BR>void WriteChart(uchar Xpos,uchar Ypos,char
c)<BR>{ <WBR> <WBR><BR>LcdPos(Xpos,Ypos);<BR> <WBR>Write_data(c);<BR> <WBR>
<WBR>}<BR>void init()<BR>{<BR>E=0;<BR>Write_com(0x38,0);<BR> <WBR>
Write_com(0x38,1);<BR> <WBR>Write_com(0x0c,1);<BR> <WBR>
Write_com(0x01,1);<BR> <WBR>Write_com(0x06,1);<BR>}</P>
<P>void main()<BR>{<BR>uchar i=0,n=0,j=0,m=0;</P>
<P>P3_4=0;<BR> <WBR> <WBR> init();<BR> <WBR> <WBR>
delay(10);<BR> <WBR> <WBR>
//写入自编字库<BR>for(j=0;j<8;j++)<BR>{<BR> <WBR> <WBR>
for(n=0;n<8;n++)<BR> <WBR>{<BR> <WBR> <WBR> <WBR>
WriteChar(i,s[j][n]);<BR> <WBR>i++
; <WBR><BR> <WBR>}<BR> <WBR>i-=8;<BR> <WBR>i+=0x08;<BR> <WBR>}<BR> <WBR>j=4000;<BR> <WBR>n=0;<BR>delay(10); <WBR><BR>//开始现实程序。<BR> <WBR>WriteChart(0,0,0x00); <WBR> <WBR>
//小人站立 。<BR>delay(500);<BR> <WBR>
Write_com(0x01,0); <WBR><BR> <WBR>WriteChart(1,0,0x01);//开始走。<BR> <WBR>
delay(500);<BR> <WBR> <WBR>
Write_com(0x01,0);<BR> <WBR> <WBR> for(n=0;n<2;n++)//开始跑, 且速度越来越快
。<BR> <WBR> <WBR> {<BR> <WBR> <WBR>
if(n==1)<BR> <WBR> <WBR> {<BR> <WBR> <WBR>
WriteChart(0,1,0x02);<BR> <WBR> <WBR> <WBR>
delay(j);<BR> <WBR> j-=10;<BR> <WBR> Write_com(0x01,0);<BR> <WBR>
WriteChart(1,1,0x02);<BR> <WBR> <WBR> <WBR>
delay(j);<BR> <WBR> j-=10;<BR> <WBR>
Write_com(0x01,0);<BR> <WBR> <WBR>
}<BR> <WBR>for(i=2;i<16;i++)<BR> <WBR>{<BR> <WBR>WriteChart(i,n,0x02);<BR> <WBR>
delay(j);<BR> <WBR>
j-=5;<BR> <WBR>Write_com(0x01,0);<BR> <WBR>}<BR> <WBR>}<BR> <WBR>j=40;<BR> <WBR>n=0;<BR> <WBR>//小人跑完全屏之后开始显示烟花程序。<BR> <WBR>for(i=0;i<15;i++) <WBR>//烟花起飞,且速度越来越慢。<BR> <WBR>{<BR> <WBR>WriteChart(i,0,0x03);<BR> <WBR>
WriteChart(i,1,0x03);<BR> <WBR> delay(j);<BR> <WBR>
j+=10;<BR> <WBR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -