LED摇摇棒很好地利用了人眼的视觉暂留特性。摇摇棒配合手的左右摇晃就可呈现一幅完整的画面,可以显示字符、图片等。![]()
led摇摇棒电路原理图
![]() ![]() ![]()
/*******************************************
* 摇摇棒显示程序(10个切换) ** 设计者:贺显云 * * 设计时间:2010年10月15日 * * QQ:513696765 * *******************************************/ #include<reg52.h> #define unchar unsigned char#p#分页标题#e# #define unint unsigned int int i,j; sbit key=P2^7; int k; //************延时函数**************** void delay(unchar xms) { unchar m,n; for(m=0;m<xms;m++) for(n=0;n<150;n++); } #p#分页标题#e#//************键盘检测************* void keyscan() { if(key==0) { delay(10); if(key==0) { k++; while(!key); if(k>10) #p#分页标题#e# k=0; } } } //***************************************** unsigned char code table_0[]={ 0xff,0xff,0xff,0xff,0xe0,0x0f,0xed,0xdf, 0xed,0xdf,0xed,0xdf,0xed,0xdf,0x00,0x03, 0xed,0xdd,0xed,0xdd,0xed,0xdd,0xed,0xdd, 0xe0,0x0d,0xff,0xfd,0xff,0xf1,0xff,0xff, 0xff,0x7f,0xff,0x7f,0xbf,0x7f,0xbf,0x7f, #p#分页标题#e#0xbf,0x7f,0xbf,0x7d,0xbf,0x7e,0xb8,0x01, 0xb7,0x7f,0xaf,0x7f,0x9f,0x7f,0xbf,0x7f, 0xff,0x7f,0xfe,0x7f,0xff,0x7f,0xff,0xff, 0xf7,0xff,0xf7,0xff,0x00,0x01,0xf7,0xff, 0xf7,0xff,0xf7,0x3d,0xec,0xfb,0xef,0xe7, 0xef,0x1f,0x00,0xff,0xef,0xfb,0xef,0xfd, 0xe0,0x03,0xfe,0xff,0xff,0x3f,0xff,0xff, 0xfe,0xff,0xfd,0xff,0xfd,0xbd,0xfb,0xb8, 0xf5,0xb5,0xed,0xad,0xdd,0x9d,0x3d,0xb9, 0xdd,0xbb,0xed,0xbb,0xf5,0xab,0xfb,0xb0, 0xf9,0xb9,0xfc,0xff,0xfd,0xff,0xff,0xff}; //显示"电子协会"的字模 #p#分页标题#e#unsigned char code table_1[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xd7,0xfb,0xdb,0xf7,0xdd,0xcd,0xde,0x3d, 0xd9,0x3d,0xc7,0xcb,0xfb,0xfb,0xe7,0xf7, 0x0f,0xcf,0xe8,0x3f,0xef,0x9f,0xef,0xe7, 0xeb,0xf3,0xe7,0xf9,0xef,0xfb,0xff,0xff, 0xfd,0xfd,0x7d,0xfb,0x8c,0x07,0xdf,0xfb, 0xff,0xfd,0xc0,0x1d,0xdf,0xbd,0xbf,0x7d, 0xbf,0xfd,0xc0,0x05,0xdf,0xfd,0xdf,0xbd, 0xdf,0xdd,0xc0,0x3d,0xff,0xfd,0xff,0xff, 0xfe,0xff,0xfd,0xff,0xf0,0x01,0xcb,0xff,#p#分页标题#e# 0x3d,0xf7,0xfb,0xcf,0xe6,0x3f,0x0f,0x7b, 0xaf,0xfd,0xe8,0x03,0xef,0xff,0xee,0xff, 0xeb,0x3f,0xc7,0xc7,0xef,0xef,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; //显示"欢迎你"的字模 unsigned char code table_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,0xfd,0xff,0xfd,0xff, #p#分页标题#e#0xfc,0xfd,0xfc,0x63,0xfc,0x03,0xf8,0x07, 0xc0,0x07,0x00,0x0f,0xc0,0x07,0xf8,0x07, 0xfc,0x03,0xfc,0x63,0xfc,0xfd,0xfd,0xff, 0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xfd,0xff,0xfd,0xff, 0xfc,0xfd,0xfd,0x63,0xfd,0x9b,0xfb,0xf7, 0xc7,0xf7,0x3f,0xef,0xc7,0xf7,0xfb,0xf7, 0xfd,0x9b,0xfd,0x63,0xfc,0xfd,0xfd,0xff, 0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; //显示"★"的字模#p#分页标题#e# unsigned char code table_3[]={ 0xff,0xff,0xfd,0xfe,0xbd,0xfd,0xbd,0xfb, 0xbd,0xf7,0xbd,0xef,0xbd,0x9f,0x80,0x7f, 0xbd,0xbf,0xbd,0xdf,0xbd,0xef,0xbd,0xf7, 0xbd,0xf3,0xbd,0xf9,0xfd,0xfb,0xff,0xff, 0xff,0xff,0xfd,0xfe,0xbd,0xfd,0xbd,0xfb, 0xbd,0xf7,0xbd,0xef,0xbd,0x9f,0x80,0x7f, 0xbd,0xbf,0xbd,0xdf,0xbd,0xef,0xbd,0xf7, 0xbd,0xf3,0xbd,0xf9,0xfd,0xfb,0xff,0xff, 0xf1,0xff,0xff,0xff,0x00,0x00,0xef,0xff, #p#分页标题#e#0xf2,0xfe,0xee,0xfd,0xee,0xf3,0xee,0x8f, 0x00,0x7f,0xee,0x9f,0xee,0xef,0xee,0xf3, 0xe0,0xf9,0xfe,0xfc,0xfe,0xfd,0xff,0xff, 0xff,0xff,0xff,0xfb,0xfd,0xe7,0xc0,0xcf, 0xdd,0x1f,0xdd,0xb7,0xdd,0xfb,0x9d,0xfd, 0xa0,0x03,0xbd,0xff,0x3d,0xff,0x3d,0xbf, 0xbd,0xcf,0xfd,0xe3,0xff,0xf7,0xff,0xff}; //显示"天天快乐"的字模 unsigned char code table_4[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xf8,0x0f,0xf7,0xf7,0xef,0xfb,0xef,0xfb, 0xf7,0xf7,0xf8,0x0f,0xff,0xff,0xff,0xff, #p#分页标题#e#0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xf7,0xfb,0xf7,0xfb,0xe0,0x03,0xff,0xfb, 0xff,0xfb,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xf1,0xf3,0xef,0xeb,0xef,0xdb,0xef,0xbb, 0xee,0x7b,0xf1,0xf3,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xf3,0xe7,0xef,0xfb,0xee,0xfb,0xee,0xfb, 0xed,0x77,0xf3,0x8f,0xff,0xff,0xff,0xff,#p#分页标题#e# 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; //显示"0123"的字模 unsigned char code table_5[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x7f,0xfe,0x7f,0xfe,0x00,0x00, 0x00,0x00,0x7f,0xfe,0x7f,0xfe,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xf1,0xff,0xe0,0xff, 0xc0,0x7f,0x80,0x3f,0x00,0x1f,0x00,0x0f, 0x00,0x07,0x80,0x03,0xc0,0x01,0xf0,0x00, 0xc0,0x01,0x80,0x03,0x00,0x07,0x00,0x0f, 0x00,0x1f,0x80,0x3f,0xc0,0x7f,0xe0,0xff,#p#分页标题#e# 0xf1,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x00,0x03,0x00,0x01, 0x00,0x01,0xff,0xf8,0xff,0xf8,0xff,0xf8, 0xff,0xf8,0xff,0xf8,0xff,0xf8,0xff,0xf8, 0xff,0xf8,0x00,0x00,0x00,0x01,0x00,0x03, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};// 显示"I ❤ U"的字模 unsigned char code table_6[]={ 0xff,0xff,0xff,0xff,0xe0,0x0f,0xed,0xdf, 0xed,0xdf,0xed,0xdf,0xed,0xdf,0x00,0x03, 0xed,0xdd,0xed,0xdd,0xed,0xdd,0xed,0xdd,#p#分页标题#e# 0xe0,0x0d,0xff,0xfd,0xff,0xf1,0xff,0xff, 0xff,0x7f,0xff,0x7f,0xbf,0x7f,0xbf,0x7f, 0xbf,0x7f,0xbf,0x7d,0xbf,0x7e,0xb8,0x01, 0xb7,0x7f,0xaf,0x7f,0x9f,0x7f,0xbf,0x7f, 0xff,0x7f,0xfe,0x7f,0xff,0x7f,0xff,0xff, 0xef,0x7f,0xef,0x7d,0xee,0xfe,0x00,0x01, 0xed,0xff,0xeb,0xfd,0xff,0xfd,0xec,0xfb, 0xed,0x37,0xed,0xcf,0x01,0xcf,0xed,0xb7, 0xec,0x7b,0xed,0xf9,0xef,0xfb,0xff,0xff, 0xf7,0xf7,0xf7,0xf7,0xf7,0xef,0xf7,0xdf, 0xf7,0xbf,0xf6,0x7f,0xf5,0xff,0x00,0x01, #p#分页标题#e#0xf5,0xff,0xf6,0xff,0xb7,0x7f,0xd7,0x9f, 0xf7,0xcf,0xf7,0xe7,0xf7,0xef,0xff,0xff};//显示"电子技术"的字模 unsigned char code table_7[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb, 0xbf,0xfb,0xbe,0xfb,0xbe,0xfb,0xbe,0xfb, 0xbe,0xfb,0xbe,0xfb,0x80,0x03,0xbe,0xfb, 0xbe,0xfb,0xbe,0xfb,0xbe,0xfb,0x3c,0xfb, 0xbe,0xf3,0xff,0xfb,0xff,0xff,0xff,0xff, 0xff,0xff,0xc0,0x1f,0xef,0xbf,0xef,0xbf, 0xef,0xbf,0xef,0xbf,0x00,0x00,0xef,0xbf, 0xef,0xbf,0xef,0xbf,0xef,0xbf,0xc0,0x1f,#p#分页标题#e# 0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xfb, 0xbf,0xfb,0xbe,0xfb,0xbe,0xfb,0xbe,0xfb, 0xbe,0xfb,0xbe,0xfb,0x80,0x03,0xbe,0xfb, 0xbe,0xfb,0xbe,0xfb,0xbe,0xfb,0x3c,0xfb, 0xbe,0xf3,0xff,0xfb,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};//显示"王中王"的字模 unsigned char code table_8[]={ 0xff,0xff,0xff,0xff,0x80,0x00,0xb6,0xfd, 0xb6,0xfb,0xb6,0xf7,0xb6,0xff,0xb0,0xff, 0xb6,0x3f,0xb6,0xcf,0xb6,0xf7,0x86,0xfb,#p#分页标题#e# 0xfe,0xfd,0xfe,0xf0,0xff,0xff,0xff,0xff, 0xdf,0xfb,0xd8,0x03,0xdf,0xf7,0xdf,0xf7, 0xc0,0x0d,0xdd,0xed,0xdd,0x5d,0xdc,0xfb, 0xf2,0xfb,0x07,0x37,0xb7,0xcf,0xf7,0x37, 0xf0,0xfb,0xf7,0xf9,0xf7,0xfb,0xff,0xff, 0xfd,0xff,0xf3,0xbf,0xf7,0xbf,0xb7,0xbf, 0xc5,0xbf,0xd5,0xbf,0xf5,0xbd,0x75,0xbe, 0x85,0x01,0xd4,0xbf,0xf5,0xbf,0xe7,0xbf, 0x15,0xbf,0xb3,0xbf,0xf7,0xbf,0xff,0xff, 0x80,0x00,0xbf,0xff,0xb3,0xbf,0xad,0xdf, 0x9e,0x3e,0xcf,0x7d,0xdb,0x73,0xdb,0x0f, #p#分页标题#e#0x5b,0x7f,0x9b,0x7f,0xdb,0x01,0xdb,0x7e, 0xdb,0x7e,0xcf,0x7e,0xdf,0x70,0xff,0xff};//显示"民政学院"的字模 unsigned char code table_9[]={ 0xff,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff, 0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff, 0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff, 0xfe,0xff,0xfc,0xff,0xfe,0xff,0xff,0xff, 0xff,0x7f,0xfe,0xfd,0xf9,0xfd,0x87,0x7d, 0xf7,0x7d,0xf7,0x7d,0xf7,0x7d,0xf7,0x7d, 0x00,0x01,0xb7,0x7d,0xf7,0x7d,0xf7,0x7d, 0xe6,0x7d,0xf7,0x79,0xff,0xfd,0xff,0xff, 0xff,0xbf,0xdf,0x7f,0xde,0xff,0xdd,0xff,#p#分页标题#e# 0xd8,0x00,0xd3,0x6f,0xcb,0x6f,0x1b,0x6f, 0xdb,0x6b,0xdb,0x6d,0xdb,0x6c,0xd8,0x01, 0xdf,0xff,0xdf,0xff,0xdf,0xff,0xff,0xff, 0xfe,0xff,0xfd,0xff,0xf0,0x01,0xcb,0xff, 0x3d,0xf7,0xfb,0xcf,0xe6,0x3f,0x0f,0x7b, 0xaf,0xfd,0xe8,0x03,0xef,0xff,0xee,0xff, 0xeb,0x3f,0xc7,0xc7,0xef,0xef,0xff,0xff};//显示"一生有你"的字模 unsigned char code table_10[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,#p#分页标题#e# 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xf8,0x1f,0xe7,0xe7,0xdf,0xfb, 0xbf,0xfd,0x7f,0xfe,0x7f,0xfe,0xff,0xff, 0xff,0xef,0xc1,0xdf,0xbf,0xaf,0x7f,0xe7, 0xbf,0xf3,0xc1,0xf1,0xff,0xf1,0xff,0xf1, 0xff,0xf1,0xff,0xf1,0xff,0xf1,0xc1,0xf1, 0xbf,0xf3,0x7f,0xe7,0xbf,0xaf,0xc1,0xdf, 0xff,0xef,0xff,0xff,0x7f,0xfe,0x7f,0xfe, 0xbf,0xfd,0xdf,0xfb,0xe7,0xe7,0xf8,0x1f, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, #p#分页标题#e#0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};//显示"(^-^)"的字模 //***************显示函数**************** void xianshi() { for(i=0,j=1;i<=127,j<=128;i=i+2,j=j+2) { if(k==0) { P1=table_0[i],P3=table_0[j]; //显示"电子协会" #p#分页标题#e# delay(1); } else if(k==1) { P1=table_1[i],P3=table_1[j]; //显示"欢迎你" delay(1); } else if(k==2) {#p#分页标题#e# P1=table_2[i],P3=table_2[j]; //显示"★" delay(1); } else if(k==3) { P1=table_3[i],P3=table_3[j]; //显示"天天快乐" delay(1); } else if(k==4)#p#分页标题#e# { P1=table_4[i],P3=table_4[j]; //显示"0123" delay(1); } else if(k==5) { P1=table_5[i],P3=table_5[j]; // 显示"I ❤ U" delay(1); } #p#分页标题#e# else if(k==6) { P1=table_6[i],P3=table_6[j]; //显示"电子技术" delay(1); } else if(k==7) { P1=table_7[i],P3=table_7[j]; //显示"王中王" delay(1);#p#分页标题#e# } else if(k==8) { P1=table_8[i],P3=table_8[j]; //显示"民政学院" delay(1); } else if(k==9) { P1=table_9[i],P3=table_9[j]; //显示"一生有你"#p#分页标题#e# delay(1); } else if(k==10) { P1=table_10[i],P3=table_10[j]; //显示"(^-^)" delay(1); } } }#p#分页标题#e# //****************主函数******************************* void main(void) { while(1) { keyscan(); xianshi(); } } (责任编辑:admin) |