微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 摇摇棒真心求助

摇摇棒真心求助

时间:10-02 整理:3721RD 点击:
最近做了摇摇棒,程序烧写上英语字母显示不了,只显示汉字,怎么回事?令外谁有简单的程序

你什么都没有提供,怎么知道怎么回事,坛有很多人做过,自己找一下

晕  什么都么有  怎么看啊怎么帮?

这是电路图


实物图


# include <at89x51.h>
# include <stdio.h>
/**********************************************************
程序名称:LED摇摇棒显示64*16像素
简要说明:外部中断方式INT0显示;取模方式:纵向取模、字节倒序
编 写:lisongze
最后更新:12/12/12
**********************************************************/
#define uchar unsigned char
#define uint unsigned int //宏定义
#define KEY P3_0 //定义画面切换按键
uchar KY; //KY作用在后面说明  
uchar disp; //显示汉字指针
uchar pic=0,num=0; //pic为按键次数;num为中断次数
uchar code love[] = {
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*/
};
uchar code loveyou[] = {
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,/*心形图案*/
};
uchar code hehe[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,
0xF0,0x0F,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,
0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,
0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x04,0x20,0x08,0x10,
0xF0,0x0F,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*呵呵o(∩_∩)o图案*/
};
unsigned char code hanzi[] = {
/*欣*/
0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x00,
0x44,0x00,0xC2,0x7F,0x43,0x80,0x42,0x40,
0x20,0x30,0x1F,0x0C,0xD0,0x03,0x10,0x0C,
0x10,0x30,0x50,0xC0,0x30,0x40,0x00,0x00,
/*欣*/
0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x00,
0x44,0x00,0xC2,0x7F,0x43,0x80,0x42,0x40,
0x20,0x30,0x1F,0x0C,0xD0,0x03,0x10,0x0C,
0x10,0x30,0x50,0xC0,0x30,0x40,0x00,0x00,
/*我*/
0x20,0x00,0x24,0x08,0x24,0x48,0x24,0x84,
0xFE,0x7F,0x23,0x02,0x22,0x21,0x20,0x10,
0xFF,0x09,0x20,0x06,0x22,0x1A,0xAC,0x61,
0x20,0x80,0x30,0xE0,0x20,0x00,0x00,0x00,
/*爱*/
0x40,0x00,0xB0,0x00,0x92,0x40,0x96,0x30,
0x9A,0x8C,0x92,0x83,0xF2,0x46,0x9E,0x2A,
0x92,0x12,0x91,0x2A,0x99,0x26,0x95,0x42,
0x91,0xC0,0x50,0x40,0x30,0x00,0x00,0x00,
/*你*/
0x40,0x00,0x20,0x00,0xF8,0xFF,0x07,0x00,
0x40,0x00,0x20,0x08,0x18,0x04,0x0F,0x43,
0x08,0x80,0xC8,0x7F,0x08,0x00,0x08,0x01,
0x28,0x06,0x18,0x0C,0x00,0x00,0x00,0x00
};
/*****函数声明*****/
void display1(void);
void display2(void);
void display3(void);
void display4(void);
/*****n(us)延时子程序*****/
void DelayUs(uint N)
{
        uint x;
        for(x=0; x<=N;x++);
}
/*****中断服务程序*****/
void intersvr0(void) interrupt 0 using 1
{
        KY=~KY; //每个摇动来回水银开关会在摆幅两端分别产生下降沿中断,只提取其中一次(从左向右摇才显示)
        if(KY==0)  //初始值为0,每一次翻转一次,两次只相应一次
        {
                 num++; //计算中断次数
                 switch(pic) //选择画面         初始值为0
                 {
                         case 0:{display1();}break;
                         case 1:{display2();}break;
                         case 2:{display3();}break;
                         case 3:{display4();}break;
                         default:{display1();}  //特殊情况显示画面一
                 }
         }
}
void display1(void)
{
        uchar i;
        if(num>10){disp++;num=0;} //12个汉字分为3次显示完(每次显示4个),每中断10次切换
        if(disp>1)disp=0;
         //DelayUs(5200); //此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可
         DelayUs(4500);
         switch(disp)
         {
                 case 0:
                        for (i=0;i<32;i++){
                                P0=~hanzi[i*2];
                                 P2=~hanzi[i*2+1];
                                DelayUs(100); }       
                        break;
                case 1:
                        for (i=0;i<48;i++){
                                P0=~hanzi[64+i*2];
                                P2=~hanzi[64+i*2+1];
                                DelayUs(100); }       
                        break;
         }
}
/*****显示子程序2(LOVE)*****/
void display2(void)
{
uchar i;
DelayUs(4000);
for(i=0;i<64;i++)
{
P0=~love[i*2];
P2=~love[i*2+1];
DelayUs(120);
}
}
/*****显示子程序3(心形图案)*****/
void display3(void)
{
uchar i;
DelayUs(4000);
for(i=0;i<64;i++)
{
P0=~loveyou[i*2];
P2=~loveyou[i*2+1];
DelayUs(120);
}
}
/*****显示子程序4(呵呵o(∩_∩)o图案)*****/
void display4(void)
{
uchar i;
DelayUs(4000);
for(i=0;i<64;i++)
{
P0=~hehe[i*2];
P2=~hehe[i*2+1];
DelayUs(120);
}
}
/*****主函数*****/
void main(void)
{
        IT0=1;
        EX0=1;
        EA=1; //开中断,下降沿中断
        KY=0;
        while(1) //主程序中只检测按键
        {
                 if(KEY==0) //画面切换键按下
                 {
                         DelayUs(20000); //按键去抖
                         if(KEY==0);
                         pic++;
                 }
                 if(pic>3)pic=0;
        }
}
/*****END*****/

显示出来字也不完整


真心求助。


接口接错了吧?! P2.0-P2.7这些排接口。反过来接了!

学习学习                                

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top