收藏 分销(赏)

444灯立方程序(21种图案变化)说课讲解.doc

上传人:天**** 文档编号:3846846 上传时间:2024-07-22 格式:DOC 页数:16 大小:51.50KB 下载积分:8 金币
下载 相关 举报
444灯立方程序(21种图案变化)说课讲解.doc_第1页
第1页 / 共16页
444灯立方程序(21种图案变化)说课讲解.doc_第2页
第2页 / 共16页


点击查看更多>>
资源描述
444灯立方程序(21种图案变化) 精品文档 #include <reg52.h> #include <intrins.h> #define uint unsigned int #define uchar unsigned char sbit floor1=P0^0; sbit floor2=P0^1; sbit floor3=P0^2; sbit floor4=P0^3; uchar table00[]={1,0,1,0,1,0,1,0,1}; uchar table01[]={0,1,1,1,0,1,1,1}; uchar table10[]={0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1}; uchar dibu_shexing1[]={0x01,0x02,0x04,0x08, 0x10,0x10,0x08,0x04, 0x02,0x01,0x80,0x80, 0x40,0x20,0x20,0x40}; uchar dibu_shexing2[]={0x01,0x02,0x04,0x08, 0x10,0x20,0x40,0x80, 0x80,0x40,0x20,0x10, 0x08,0x04,0x02,0x01}; uchar dibu_lifang[]={0x09,0x09}; uchar dibu_tiao[]={0x0f,0xf0,0xf0,0x0f}; //.......延时......................................// void delayms(uint z) { uint i,j; for(i=z;i>0;i--) for(j=110;j>0;j--); } //...............模式0(左右移动)...........................// void display0() { uchar w; w=1; P0=0xf0; //..............阴极层拉低 while(w--) { P1=0x00; P2=0x0f; delayms(360); P1=0x00; P2=0xf0; delayms(360); P1=0xf0; P2=0x00; delayms(360); P1=0x0f; P2=0x00; delayms(360); P1=0xf0; P2=0x00; delayms(360); P1=0x00; P2=0xf0; delayms(360); P1=0x00; P2=0x0f; delayms(360); } } //...............模式1(上下移动)...........................// void display1() { uchar a; a=1; P1=0xff; while(a--) { P2=0xff; P0=0xfe; delayms(360); P2=0xff; P0=0xfd; delayms(360); P2=0xff; P0=0xfb; delayms(360); P2=0xff; P0=0xf7; delayms(360); P2=0xff; P0=0xfb; delayms(360); P2=0xff; P0=0xfd; delayms(360); P2=0xff; P0=0xfe; delayms(360); } } //.....................模式2(前后移动)..................// void display2() { uchar b; b=1; P0=0xf0; while(b--) { P1=0x81; P2=0x81; delayms(360); P1=0x42; P2=0x42; delayms(360); P1=0x24; P2=0x24; delayms(360); P1=0x18; P2=0x18; delayms(360); P1=0x24; P2=0x24; delayms(360); P1=0x42; P2=0x42; delayms(360); P1=0x81; P2=0x81; delayms(360); } } //................模式3(回字蛇形)......................// void display3() { uchar c; c=2; P0=0xf0; while(c--) { P1=0x00; P2=0x01; delayms(120); P1=0x00; P2=0x02; delayms(120); P1=0x00; P2=0x04; delayms(120); P1=0x00; P2=0x08; delayms(120); P1=0x00; P2=0x10; delayms(120); P2=0x00; P1=0x08; delayms(120); P2=0x00; P1=0x08; delayms(120); P2=0x00; P1=0x04; delayms(120); P2=0x00; P1=0x02; delayms(120); P2=0x00; P1=0x01; delayms(120); P2=0x00; P1=0x80; delayms(120); P1=0x00; P2=0x80; delayms(120); P1=0x00; P2=0x40; delayms(120); P1=0x00; P2=0x20; delayms(120); P2=0x00; P1=0x20; delayms(120); P2=0x00; P1=0x40; delayms(120); //..............// P2=0x00; P1=0x20; delayms(120); P1=0x00; P2=0x20; delayms(120); P1=0x00; P2=0x40; delayms(120); P1=0x00; P2=0x80; delayms(120); P2=0x00; P1=0x80; delayms(120); P2=0x00; P1=0x01; delayms(120); P2=0x00; P1=0x02; delayms(120); P2=0x00; P1=0x04; delayms(120); P2=0x00; P1=0x08; delayms(120); P1=0x00; P2=0x10; delayms(120); P1=0x00; P2=0x08; delayms(120); P1=0x00; P2=0x04; delayms(120); P1=0x00; P2=0x02; delayms(120); P1=0x00; P2=0x01; delayms(120); } } //.............. 模式4 (波形蛇形)........................// void display4() { uchar d=2; P0=0x00; while(d--) { P1=0x00; P2=0x01; delayms(120); P1=0x00; P2=0x02; delayms(120); P1=0x00; P2=0x04; delayms(120); P1=0x00; P2=0x08; delayms(120); P1=0x00; P2=0x10; delayms(120); P1=0x00; P2=0x20; delayms(120); P1=0x00; P2=0x40; delayms(120); P1=0x00; P2=0x80; delayms(120); P2=0x00; P1=0x80; delayms(120); P2=0x00; P1=0x40; delayms(120); P2=0x00; P1=0x20; delayms(120); P2=0x00; P1=0x10; delayms(120); P2=0x00; P1=0x08; delayms(120); P2=0x00; P1=0x04; delayms(120); P2=0x00; P1=0x02; delayms(120); P2=0x00; P1=0x01; delayms(120); } } //....................模式5(魔方变换)............................// void display5() { uchar e; e=2; while(e--) { P0=0xf9; P1=0x60; P2=0x60; delayms(700); P0=0xf6; P1=0x09; P2=0x09; delayms(700); } } //.....................模式6(乱阵)......................// void display6() { uchar f; f=2; while(f--) { P0=0xf6; P1=0x0f; P2=0x0f; delayms(500); P0=0xf6; P2=0xf0; P1=0xf0; delayms(500); P0=0xf6; P1=0xf0; P2=0xf0; delayms(500); P0=0xf6; P2=0x0f; P1=0x0f; delayms(500); P0=0xf0; P1=0x09; P2=0x09; delayms(500); P0=0xf0; P1=0xf6; P2=0xf6; delayms(500); } } //...................模式7(边框显示)......................// void display7() { uchar g; g=1; while(g--) { P0=0xf6; P1=0x0f; P2=0x0f; delayms(0.1);//..........扫描.......... P0=0x06; P1=0x99; P2=0x99; delayms(0.001);//.........扫描........... P0=0xf0; P1=0x09; P2=0x09; delayms(0.1);//.........扫描.......... } } //................8(中央正方显示).................// void display8() { uchar k; k=1; P0=0xf9; while(k--) { P1=0x60; P2=0x60; } } //.................9(全亮与全灭)..........................// void display9() { uchar h; h=3; while(h--) { P0=0xf0; P1=0xff; P2=0xff; delayms(120); P0=0xff; P1=0xff; P2=0xff; delayms(120); } } //...................10moshi(外围面逆时针转动).........// void display10() { uchar l; l=3; P0=0xf0; while(l--) { P1=0x00; P2=0x0f; delayms(160); P1=0x81; P2=0x81; delayms(160); P1=0x0f; P2=0x00; delayms(160); P1=0x18; P2=0x18; delayms(160); } } //......................11mosji(外围面顺时针转动)..........// void display11() { uchar m; m=3; P0=0xf0; while(m--) { P1=0x00; P2=0x0f; delayms(160); P1=0x18; P2=0x18; delayms(160); P1=0x0f; P2=0x00; delayms(160); P1=0x81; P2=0x81; delayms(160); } } //....................12(外表面流动显示)..................// void display12() { uchar n; n=5; P0=0xf0; while(n--) { P1=0x00; P2=0x0f; delayms(40); P1=0x00; P2=0x87; delayms(40); P1=0x80; P2=0x83; delayms(40); P1=0x81; P2=0x81; delayms(40); P1=0x83; P2=0x80; delayms(40); P1=0x87; P2=0x00; delayms(40); P1=0x0f; P2=0x00; delayms(40); P1=0x1e; P2=0x00; delayms(40); P1=0x1c; P2=0x10; delayms(40); P1=0x18; P2=0x18; delayms(40); P1=0x10; P2=0x1c; delayms(40); P1=0x00; P2=0x1e; delayms(40); P1=0x00; P2=0x0f; } } //...................13(ni).......................// void display13() { uchar o; o=5; P0=0xf0; while(o--) { P1=0x00; P2=0x0f; delayms(40); P1=0x00; P2=0x1e; delayms(40); P1=0x10; P2=0x1c; delayms(40); P1=0x18; P2=0x18; delayms(40); P1=0x1c; P2=0x10; delayms(40); P1=0x1e; P2=0x00; delayms(40); P1=0x0f; P2=0x00; delayms(40); P1=0x87; P2=0x00; delayms(40); P1=0x83; P2=0x80; delayms(40); P1=0x81; P2=0x81; delayms(40); P1=0x80; P2=0x83; delayms(40); P1=0x00; P2=0x87; delayms(40); P1=0x00; P2=0x0f; delayms(40); } } //............................14(对角放大显示)...............// void display14() { uchar p; p=2; while(p--) { P0=0xfe; P1=0x00; P2=0x08; delayms(160); P0=0xfc; P1=0x00; P2=0x3c; delayms(200); P0=0xf8; P1=0x70; P2=0x7e; delayms(240); P0=0xf0; P1=0xff; P2=0xff; delayms(280); P0=0xf1; P1=0xe7; P2=0xe0; delayms(240); P0=0xf3; P1=0xc3; P2=0x00; delayms(200); P0=0xf7; P1=0x01; P2=0x00; delayms(160); P0=0xf3; P1=0xc3; P2=0x00; delayms(200); P0=0xf1; P1=0xe7; P2=0xe0; delayms(240); P0=0xf0; P1=0xff; P2=0xff; delayms(280); P0=0xf8; P1=0x70; P2=0x7e; delayms(240); P0=0xfc; P1=0x00; P2=0x3c; delayms(200); P0=0xfe; P1=0x00; P2=0x08; delayms(160); } } //.......................15(点火显示).................// void display15() { uchar q,r,s,t,u,v; q=1; P2=P1; while(q--) { s=0xfe; t=0x01; v=0x01; for(r=0;r<=3;r++) { P0=s; s=_crol_(s,1); for(u=0;u<=7;u++) { P2=t; P1=v; t=_crol_(t,1); v=_crol_(v,1); delayms(100); } } } } //...............................................// void main() { while(1) { display9(); delayms(200); display14(); display5(); delayms(100); display1(); delayms(200); display2(); delayms(200); display0(); delayms(200); display6(); display14(); display15(); display8(); display12(); display13(); display6(); display3(); display4(); display15(); display10(); display11(); display12(); display14(); display6(); display15(); delayms(240); display7(); display9(); } } 收集于网络,如有侵权请联系管理员删除
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服