摇摇棒原理图和PCB图及程序.docx
《摇摇棒原理图和PCB图及程序.docx》由会员分享,可在线阅读,更多相关《摇摇棒原理图和PCB图及程序.docx(11页珍藏版)》请在冰豆网上搜索。
摇摇棒原理图和PCB图及程序
在此,摇摇棒的原理就不说了,下面是我做的摇摇棒,附原理图,和PCB图:
上面是原理图。
S1为水银开关,上拉电阻10k。
上图为PCB图,从下到上为D1~D16,D1~D8由~控制,D9~D16由~控制。
图像切换有控制。
注意水银开关与水平方向成45度角放置。
注意本图连接采用PCtoLCD2002取模,取模方式为:
逐列,逆向,阴码。
如图设置:
如有问题,请,一起讨论学习。
下面是程序:
#include<>
#defineucharunsignedchar
#defineuintunsignedint
sbitkey=P2^0;//定义切换画面开关
ucharKey_num;//定义按键次数
ucharInt0_num=0;//定义中断次数
ucharDirection;//定义摇动方向(从左到右)
ucharcodeEmbed[]={
0x00,0x00,0x08,0x00,0x08,0x20,0xFE,0x1F,
0x08,0x08,0x08,0x10,0x08,0x10,0xF8,0x0F,
0x00,0x00,0xF8,0x0F,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0xF8,0x0F,0x00,0x00,/*"加",0*/
0x00,0x00,0x80,0x20,0x10,0x11,0x20,0x0A,
0x00,0x04,0x00,0x02,0xE0,0x1F,0x20,0x11,
0x20,0x11,0x20,0x11,0xFE,0x1F,0x20,0x11,
0x20,0x11,0x20,0x11,0xE0,0x1F,0x00,0x00,/*"油",0*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF8,0x03,0x48,0x02,0x48,0x02,0x48,0x02,
0xFE,0x1F,0x48,0x22,0x48,0x22,0x48,0x22,
0xF8,0x23,0x00,0x18,0x00,0x00,0x00,0x00,/*"电",0*/
0x00,0x00,0x00,0x00,0x80,0x00,0x88,0x00,
0x88,0x40,0x88,0x80,0x88,0x80,0xC8,0xFF,
0xA8,0x00,0x98,0x00,0x88,0x00,0x80,0x00,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"子",0*/
0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,
0x02,0x00,0x02,0x00,0x02,0x60,0xC2,0x6F,
0x62,0x60,0x36,0x00,0x1C,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"",0*/
};
ucharcodelove[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x08,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*LOVE*/};
ucharcodelove_picture[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*心形图案*/};
ucharcodeHello[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"",0*/
0x08,0x20,0xF8,0x3F,0x08,0x21,0x00,0x01,0x00,0x01,0x08,0x21,0xF8,0x3F,0x08,0x20,/*"H",1*/
0x00,0x00,0x00,0x1F,0x80,0x22,0x80,0x22,0x80,0x22,0x80,0x22,0x00,0x13,0x00,0x00,/*"e",2*/
0x00,0x00,0x08,0x20,0x08,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"l",3*/
0x00,0x00,0x08,0x20,0x08,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"l",4*/
0x00,0x00,0x00,0x1F,0x80,0x20,0x80,0x20,0x80,0x20,0x80,0x20,0x00,0x1F,0x00,0x00,/*"o",5*/
0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x33,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,/*"!
",6*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"",7*/};
ucharcodeSmile[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x1F,0x3C,0x3C,0x0E,0xF7,0x06,0xEF,0xF3,0xDC,0xF3,0xB0,0x63,0xB0,0x03,0xB0,0xF3,0xB0,0xF3,0xB8,0x03,0xDD,0x06,0xEF,0x0E,0x76,0x3C,0x3C,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ucharcodeHxembed_Make[]={
0x00,0x00,0x60,0x00,0xF0,0x09,0x10,0x07,
0xD0,0x07,0x70,0x0C,0x00,0x88,0x00,0x98,
0x00,0xC0,0x20,0x70,0x38,0x1C,0x1E,0x07,
0xFA,0x3E,0x08,0x60,0x68,0x80,0x18,0x00,/*"欢",0*/
0x10,0x04,0x18,0x08,0xF0,0x0F,0x08,0x18,
0xFC,0x10,0x02,0x11,0x00,0x11,0x00,0x11,
0x80,0x10,0xFC,0x17,0x84,0x10,0x04,0x11,
0x04,0x11,0xFC,0x10,0x00,0x08,0x00,0x00,/*"迎",0*/
0x00,0x00,0x00,0x00,0xC0,0x00,0xB8,0x1E,0xA0,0x02,0xFE,0x3F,0xA4,0x02,0x60,0x02,
0x50,0x1E,0x00,0x00,0xE0,0x03,0x00,0x00,0x14,0x60,0xEC,0x3F,0x00,0x00,0x00,0x00,/*"制",7*/
0x00,0x00,0x00,0x01,0x80,0x00,0x40,0x00,0xF0,0x3F,0x0C,0x00,0x80,0x00,0x40,0x00,
0x30,0x00,0xEE,0x7E,0x20,0x09,0x20,0x09,0x20,0x05,0x10,0x00,0x00,0x00,0x00,0x00/*"作",8*/};
ucharcodeThanks[]={
//--谢--//
0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x52,0xFC,0x2B,0x56,0x12,0x55,0x4A,0x54,0x86,
0xFE,0x7F,0x24,0x01,0x20,0x46,0x20,0x80,0xFF,0x7F,0x20,0x00,0x20,0x00,0x00,0x00,//--谢--
0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x52,0xFC,0x2B,0x56,0x12,0x55,0x4A,0x54,0x86,
0xFE,0x7F,0x24,0x01,0x20,0x46,0x20,0x80,0xFF,0x7F,0x20,0x00,0x20,0x00,0x00,0x00,//--!
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0xFE,0x3B,0xFE,0x3B,0x7C,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ucharcodedanpan_picture[]={
0x7f,0xff,0x7f,0xbf,0x7f,0xcf,0x7f,0xf3,0x01,0xfc,0x7d,0xff,0x75,0xff,0x6d,0xff,0x0d,0xff,0x5d,0xdf,0x7d,0xbf,0x01,0xc0,0x7f,0xff,0x7f,0xff,0x7f,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*心形图案*/
0x9f,0xfb,0xab,0xfb,0xb3,0xfd,0x80,0xdd,0xb3,0xd6,0x28,0xd5,0x92,0x55,0xad,0x01,0x92,0xd5,0xab,0xd5,0x33,0xd5,0x80,0xd6,0xb3,0xdd,0xab,0xf9,0xab,0xfd,0xff,0xff};
voiddelay(uintX)
{
uinti;
for(i=0;i<=X;i++);
}
voiddelay1(uintn)
{uintx,y;
for(x=0;x<120;x++)
for(y=0;y}
/*'加油电子'显示32*16像素*/
voiddisplay1()
{
uchari,disp;
if(Int0_num>4)
{disp++;Int0_num=0;}
if(disp>1)disp=0;
delay(12000);
for(i=0;i<48;i++)
{
P0=~Embed[disp*64+i*2];
P1=~Embed[disp*64+i*2+1];
delay(120);//延时时间自己可以调,最好让画面显示在中间
}
}
/*'LOVE'显示64*16像素*/
voiddisplay2()
{
uchari;
delay(12000);
for(i=0;i<64;i++)
{
P0=~love[i*2];
P1=~love[i*2+1];
delay(150);
}
}
/*心形图案显示64*16像素*/
voiddisplay3()
{
uchari;
delay(12000);
for(i=0;i<64;i++)
{
P0=~love_picture[i*2];
P1=~love_picture[i*2+1];
delay(200);
}
}
/*‘Hello!
示64*16像素*/
voiddisplay4()
{
uchari;
delay(12000);
for(i=0;i<64;i++)
{
P0=~Hello[i*2];
P1=~Hello[i*2+1];
delay(120);
}
}
/*笑脸图案显示64*16像素*/
voiddisplay5()
{
uchari;
delay(12000);
for(i=0;i<64;i++)
{
P0=~Smile[i*2];
P1=~Smile[i*2+1];
delay(150);
}
}
/*‘欢迎制作显示64*16像素’*/
voiddisplay6()
{
uchari;
delay(12000);
for(i=0;i<64;i++)
{
P0=~Hxembed_Make[i*2];
P1=~Hxembed_Make[i*2+1];
delay(90);
}
}
/*'谢谢!
'显示48*16像素*/
voiddisplay7()
{
uchari;
delay(12000);
for(i=0;i<48;i++)
{
P0=~Thanks[i*2];
P1=~Thanks[i*2+1];
delay(80);
}
}
/*外部中断0子函数*/
voidint0(void)interrupt0
{
Direction=~Direction;
if(Direction==0)
{
Int0_num++;//中断次数加1
switch(Key_num)
{
case0:
display1();break;
case1:
display2();break;
case2:
display3();break;
case3:
display4();break;
case4:
display5();break;
case5:
display6();break;
case6:
display7();break;
default:
display1();
}
}
}
voidmain(void)
{
EA=1;//开总中断
IT0=1;//下降沿中断
EX0=1;//启动外部中断0你——怒目
Key_num=0;//初始化按键次数为零
while
(1){
if(!
key){
delay1(5);//去抖,可以跟自己的电路适当选择时间
if(key==0)
{
Key_num++;
if(Key_num>6)//如果超过切换页面的次数就清零
Key_num=0;
}
delay1(5);
while(!
key);
}
}
}