Proteus教程:16x16点阵显示以及流水效果

描述

视频链接:https://www.bilibili.com/video/BV1Hv4y1f7Uq

嵌入式 嵌入式 嵌入式 嵌入式
#include < reg52.h > #include< intrins.h > #define uchar unsigned char #define uint unsigned int uchar ROG[64]; uchar ROG_buff[64]; uchar l_num=0; uchar w_num; int time; bit flag; uchar play_mode; uchar stay_flag; uchar hang[]= { 0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80, 0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x80,0x00, }; uchar code lie[]= { 0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0x00,0x01,0xFE,0xFF,0xFE,0xFF, 0xFD,0x7F,0xFD,0x7F,0xFB,0xBF,0xFB,0xBF,0xF7,0xDF,0xEF,0xEF,0xDF,0xF7,0x3F,0xF9,/*"大",0*/ 0xFD,0xFF,0xFE,0xFF,0x80,0x01,0xBF,0xFD,0x7F,0xFB,0x80,0x03,0xFD,0xFF,0xF2,0xF7, 0x8E,0x6F,0xFD,0x5F,0xF3,0x3F,0x8E,0x5F,0xF9,0x67,0xE7,0x79,0x1D,0x7F,0xFE,0xFF,/*"家",1*/ 0xEF,0xFF,0xEF,0x03,0xEF,0xFB,0xEF,0xF7,0x03,0xEF,0xDB,0xDF,0xDB,0xDF,0xDA,0x01, 0xDB,0xDF,0xB7,0xDF,0xD7,0xDF,0xEF,0xDF,0xD7,0xDF,0xBB,0xDF,0x7B,0x5F,0xFF,0xBF,/*"好",2*/ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0xCF,0xFF,0xEF,0xFF,0xDF,0xFF,0xFF,0xFF,/*",",3*/ 0xFB,0xBF,0xF1,0xAF,0x87,0xB7,0xF7,0xB7,0xF7,0xBF,0x00,0x01,0xF7,0xBF,0xF7,0xBB, 0xF5,0xBB,0xF3,0xB7,0xE7,0xCF,0x97,0xDD,0xF7,0xAD,0xF7,0x75,0xD4,0xF9,0xEF,0xFD,/*"我",4*/ 0xE0,0x0F,0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,0xFF,0xFF, 0x00,0x01,0xFE,0xFF,0xEE,0xFF,0xEE,0x07,0xEE,0xFF,0xD6,0xFF,0xBA,0xFF,0x7C,0x01,/*"是",5*/ 0xF7,0xFF,0xE2,0x03,0x0E,0xFB,0xEE,0xFB,0xEE,0xFB,0x02,0x03,0xEF,0xFF,0xCF,0xFF, 0xC6,0x01,0xAB,0xDF,0xAB,0xDF,0x6E,0x03,0xEF,0xDF,0xEF,0xDF,0xEC,0x01,0xEF,0xFF,/*"程",6*/ 0xEF,0xBF,0xEF,0xDF,0xDC,0x01,0x85,0xFD,0xB3,0xFB,0xB6,0x07,0xB7,0xFF,0xB7,0xFF, 0x84,0x01,0xB7,0x6F,0xB7,0x6F,0xB7,0x6F,0xB6,0xED,0x86,0xED,0xB5,0xF1,0xFB,0xFF,/*"皖",7*/ }; sbit sh0=P1^0; sbit ds0=P1^1; sbit st0=P1^2; sbit sh1=P1^3; sbit ds1=P1^4; sbit st1=P1^5; uchar i; void delay(uchar z) { for(z;z >0;z--) for(i=110;i >0;i--); } void send0(uchar temp0) { for(i=0;i< 8;i++) { sh0=0; ds0=temp0&0x80; temp0=temp0< <1; sh0=1; } } void send1(uchar temp1) { for(i=0;i< 8;i++) { sh1=0; ds1=temp1&0x80; temp1=temp1< <1; sh1=1; } } void Send_All(int A1,int A2,int B1,int B2) { send0(A1); send1(B1); st0=0; st1=0; st0=1; st1=1; send0(A2); send1(B2); st0=0; st1=0; st0=1; st1=1; } void Show_One(uchar num) { uchar i=0,j,n; for(j=0;j< 32;j++) { send0(hang[j]); send1(lie[num*32+j]); n++; if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } } } void Show_SX(uchar num) { uchar i=0,j,n; int m,anw; if(num==1){anw = 16;} else{anw = num * 32;} for(j=0;j< 32;j++) { send0(hang[j]); send1(lie[j+m]); n++; while(stay_flag); if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } delay(1); } delay(1); m+=2; if(m==anw)m=0; } void Show_ZY(uchar num) { uchar i=0,j,n; for(j=0;j< 32;j++) { send0(hang[j]); send1(lie[num*32+j]); n++; if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } } } void Show_data() { uchar i=0,j,n; for(j=0;j< 32;j++) { send0(hang[j]); send1(ROG[j]); n++; if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } } } void Control(uchar num) { uchar i,j,m; num = num*2; time ++; if(time == 5) { time = 0; if(j==7) { j = 0; if(l_num< num) { if(flag) { for(m=0;m< 32;m++) { w_num = l_num/2; ROG_buff[2*m] = lie[w_num*32+2*m+1]; ROG_buff[2*m+1] = lie[w_num*32+32+2*m]; } flag = ~ flag; }else { for(m=0;m< 64;m++) { if(l_num!=0) { w_num = l_num/2; ROG_buff[m] = lie[w_num*32+m]; }else { ROG_buff[m] = lie[m]; } } flag = ~flag; } l_num++; }else { l_num = 0; for(m=0;m< 64;m++) { ROG_buff[m] = 0xff; } flag = 0; } }else { j++; } for(i=0;i< 16;i++) { ROG[2*i] = ROG_buff[2*i]< >(8-j); ROG[2*i+1] = ROG_buff[2*i+1]< >(8-j); } } while(stay_flag); Show_data(); } void main() { uchar m; for(m=0;m< 64;m++) { ROG_buff[m] = 0xff; } while(1) { //Show_One(3); // Control(7); Show_SX(7); } } #include < reg52.h > #include< intrins.h > #define uchar unsigned char #define uint unsigned int uchar ROG[64]; uchar ROG_buff[64]; uchar l_num=0; uchar w_num; int time; bit flag; uchar play_mode; uchar stay_flag; uchar hang[]= { 0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0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,0xFF,0xEE,0xFF,0xEE,0x07,0xEE,0xFF,0xD6,0xFF,0xBA,0xFF,0x7C,0x01,/*"是",5*/ 0xF7,0xFF,0xE2,0x03,0x0E,0xFB,0xEE,0xFB,0xEE,0xFB,0x02,0x03,0xEF,0xFF,0xCF,0xFF, 0xC6,0x01,0xAB,0xDF,0xAB,0xDF,0x6E,0x03,0xEF,0xDF,0xEF,0xDF,0xEC,0x01,0xEF,0xFF,/*"程",6*/ 0xEF,0xBF,0xEF,0xDF,0xDC,0x01,0x85,0xFD,0xB3,0xFB,0xB6,0x07,0xB7,0xFF,0xB7,0xFF, 0x84,0x01,0xB7,0x6F,0xB7,0x6F,0xB7,0x6F,0xB6,0xED,0x86,0xED,0xB5,0xF1,0xFB,0xFF,/*"皖",7*/ }; sbit sh0=P1^0; sbit ds0=P1^1; sbit st0=P1^2; sbit sh1=P1^3; sbit ds1=P1^4; sbit st1=P1^5; uchar i; void delay(uchar z) { for(z;z >0;z--) for(i=110;i >0;i--); } void send0(uchar temp0) { for(i=0;i< 8;i++) { sh0=0; ds0=temp0&0x80; temp0=temp0< <1; sh0=1; } } void send1(uchar temp1) { for(i=0;i< 8;i++) { sh1=0; ds1=temp1&0x80; temp1=temp1< <1; sh1=1; } } void Send_All(int A1,int A2,int B1,int B2) { send0(A1); send1(B1); st0=0; st1=0; st0=1; st1=1; send0(A2); send1(B2); st0=0; st1=0; st0=1; st1=1; } void Show_One(uchar num) { uchar i=0,j,n; for(j=0;j< 32;j++) { send0(hang[j]); send1(lie[num*32+j]); n++; if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } } } void Show_SX(uchar num) { uchar i=0,j,n; int m,anw; if(num==1){anw = 16;} else{anw = num * 32;} for(j=0;j< 32;j++) { send0(hang[j]); send1(lie[j+m]); n++; while(stay_flag); if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } delay(1); } delay(1); m+=2; if(m==anw)m=0; } void Show_ZY(uchar num) { uchar i=0,j,n; for(j=0;j< 32;j++) { send0(hang[j]); send1(lie[num*32+j]); n++; if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } } } void Show_data() { uchar i=0,j,n; for(j=0;j< 32;j++) { send0(hang[j]); send1(ROG[j]); n++; if(n==2) { st0=0; st1=0; st0=1; st1=1; n=0; } } } void Control(uchar num) { uchar i,j,m; num = num*2; time ++; if(time == 5) { time = 0; if(j==7) { j = 0; if(l_num< num) { if(flag) { for(m=0;m< 32;m++) { w_num = l_num/2; ROG_buff[2*m] = lie[w_num*32+2*m+1]; ROG_buff[2*m+1] = lie[w_num*32+32+2*m]; } flag = ~ flag; }else { for(m=0;m< 64;m++) { if(l_num!=0) { w_num = l_num/2; ROG_buff[m] = lie[w_num*32+m]; }else { ROG_buff[m] = lie[m]; } } flag = ~flag; } l_num++; }else { l_num = 0; for(m=0;m< 64;m++) { ROG_buff[m] = 0xff; } flag = 0; } }else { j++; } for(i=0;i< 16;i++) { ROG[2*i] = ROG_buff[2*i]< >(8-j); ROG[2*i+1] = ROG_buff[2*i+1]< >(8-j); } } while(stay_flag); Show_data(); } void main() { uchar m; for(m=0;m< 64;m++) { ROG_buff[m] = 0xff; } while(1) { //Show_One(3); // Control(7); Show_SX(7); } }

  审核编辑:汤梓红

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表德赢Vwin官网 网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分