想要更多项目私wo!!!
一、电路设计
此电路由AT89C55、液晶屏和按键模块组成。
七个按键分别为:上、下、左、右、确定、取消、暂停。
二、运行结果
三、部分代码
#include <reg52.h>
#include <12864.h>
#include <resource.h>
#include <menu.h>
struct menu_index
{
unsigned char up_num;
unsigned char down_num;
unsigned char confirm_num;
unsigned char cansel_num;
};
struct menu_index code menu_num[14]=
{
{3,1,4,0},
{0,2,5,1},
{1,3,9,2},
{2,0,12,3},
{0,0,0,0},
{8,6,5,1},
{5,7,6,1},
{6,8,7,1},
{7,5,8,1},
{11,10,9,2},
{9,11,10,2},
{10,9,11,2},
{13,13,12,3},
{12,12,13,3},
};
unsigned char present_menu_num;
extern unsigned char flag_exit_game;
extern unsigned char tcs_nd;
extern unsigned char tcs_dt;
void tcs_game();
void main()
{
present_menu_num=0;
tcs_nd=1;
tcs_dt=1;
initial_lcd();
clear_lcd();
huihui(present_menu_num);
while(1)
{
key_down();
}
}
void key_down()
{
unsigned char h;
if((P2&0x7f)!=0x7f)
{
delay_ms(10);
if ((P2&0x7f)!=0x7f)
{
h=P2&0x7f;
switch(h)
{
case 0x6f: {
present_menu_num=menu_num[present_menu_num].confirm_num;
huihui(present_menu_num);
break;
}// È·¶¨¼ü
case 0x5f: {
present_menu_num=menu_num[present_menu_num].cansel_num;
huihui(present_menu_num);
break;
}//·µ»Ø¼ü
case 0x7e: {
present_menu_num=menu_num[present_menu_num].up_num;
huihui(present_menu_num);
break;
}//¡ü
case 0x7b: break;//¡û
case 0x7d: {
present_menu_num=menu_num[present_menu_num].down_num;
huihui(present_menu_num);
break;
}//¡ý
case 0x77: break;//->
}
while( (P2&0x7f)!=0x7f );
P2=0xff;
delay_ms(10);
}
}
}