KEIL 单片机编程问题,好多错误。求大神帮改一下。万分感激
uchar;kev;can;//ucharkey_can;//按键值voidkey()//独立按键程序{staticucharkey_new;key_can=20;//按...
uchar; kev; can;
//uchar key_can; //按键值
void key() //独立按键程序
{
static uchar key_new;
key_can = 20; //按键值还原
P1 |= 0x03;
if((P1 & 0x03) != 0x03) //按键按下
{
delay_1ms(1); //按键消抖动
if(((P1 & 0x03) != 0x03) && (key_new == 1))
{ //确认是按键按下
key_new = 0;
switch(P1 & 0x03)
{
case 0x02: key_can = 2; break; //得到按键值
case 0x01: key_can = 1; break; //得到按键值
}
}
}
else //按键松开
key_new = 1;
}
void main()
{
uchar num;
P0 = P1 = P2 = P3 = 0XFF;
init_12864();
init_12864_dis();
Send_threelines(0); //语音播报
while(1)
}
key(); //独立按键程序
if(key_can < 20)
{
if(key_can == 1)
{
if(num < 10)
{
num++;
}
}
if(key_can == 2)
{
if(num != 0)
num--;
}
if(num == 1) //报第1个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 南洛高速路口 ");
write_string(3,0," (建设路) ");
Send_threelines(1,0); //语音播报
}
if(num == 2) //报第2个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 蓝湾新城小区 ");
write_string(3,0," (朱砂洞) ");
Send_threelines(2,0); //语音播报
}
if(num == 3) //报第3个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 建设大厦 ");
write_string(3,0," ");
Send_threelines(3,0); //语音播报
}
if(num == 4) //报第4个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 教育局 ");
write_string(3,0," ");
Send_threelines(4,0); //语音播报
}
if(num == 5) //报第5个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 国土资源局 ");
write_string(3,0," ");
Send_threelines(5,0); //语音播报
}
if(num == 6) //报第6个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 祥顺路口 ");
write_string(3,0," ");
Send_threelines(6,0); //语音播报
}
if(num == 7) //报第7个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 市政大厦北门 ");
write_string(3,0," (祥云公园) ");
Send_threelines(7,0); //语音播报
}
if(num == 8) //报第8个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 湖光花园小区 ");
write_string(3,0," ");
Send_threelines(8,0); //语音播报
}
if(num == 9) //报第9个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 崇文路口 ");
}
write_string(3,0," ");
Send_threelines(9,0); //语音播报
}
if(num == 10) //报第10个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 平顶山市卫校 ");
write_string(3,0," ");
Send_threelines(0x10,0); //语音播报
}
} 展开
//uchar key_can; //按键值
void key() //独立按键程序
{
static uchar key_new;
key_can = 20; //按键值还原
P1 |= 0x03;
if((P1 & 0x03) != 0x03) //按键按下
{
delay_1ms(1); //按键消抖动
if(((P1 & 0x03) != 0x03) && (key_new == 1))
{ //确认是按键按下
key_new = 0;
switch(P1 & 0x03)
{
case 0x02: key_can = 2; break; //得到按键值
case 0x01: key_can = 1; break; //得到按键值
}
}
}
else //按键松开
key_new = 1;
}
void main()
{
uchar num;
P0 = P1 = P2 = P3 = 0XFF;
init_12864();
init_12864_dis();
Send_threelines(0); //语音播报
while(1)
}
key(); //独立按键程序
if(key_can < 20)
{
if(key_can == 1)
{
if(num < 10)
{
num++;
}
}
if(key_can == 2)
{
if(num != 0)
num--;
}
if(num == 1) //报第1个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 南洛高速路口 ");
write_string(3,0," (建设路) ");
Send_threelines(1,0); //语音播报
}
if(num == 2) //报第2个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 蓝湾新城小区 ");
write_string(3,0," (朱砂洞) ");
Send_threelines(2,0); //语音播报
}
if(num == 3) //报第3个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 建设大厦 ");
write_string(3,0," ");
Send_threelines(3,0); //语音播报
}
if(num == 4) //报第4个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 教育局 ");
write_string(3,0," ");
Send_threelines(4,0); //语音播报
}
if(num == 5) //报第5个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 国土资源局 ");
write_string(3,0," ");
Send_threelines(5,0); //语音播报
}
if(num == 6) //报第6个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 祥顺路口 ");
write_string(3,0," ");
Send_threelines(6,0); //语音播报
}
if(num == 7) //报第7个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 市政大厦北门 ");
write_string(3,0," (祥云公园) ");
Send_threelines(7,0); //语音播报
}
if(num == 8) //报第8个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 湖光花园小区 ");
write_string(3,0," ");
Send_threelines(8,0); //语音播报
}
if(num == 9) //报第9个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 崇文路口 ");
}
write_string(3,0," ");
Send_threelines(9,0); //语音播报
}
if(num == 10) //报第10个站
{
write_string(1,0," 66路公交车 ");
write_string(2,0," 平顶山市卫校 ");
write_string(3,0," ");
Send_threelines(0x10,0); //语音播报
}
} 展开
意法半导体(中国)投资有限公司
2023-06-12
展开全部
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
delay_1ms(uint);
init_12864(void);
init_12864_dis(void);
Send_threelines(int, char);
write_string(char, char, char *p);
uchar key_can; //按键值
void key() //独立按键程序
{
static uchar key_new;
key_can = 20; //按键值还原
P1 |= 0x03;
if((P1 & 0x03) != 0x03) { //按键按下
delay_1ms(1); //消抖
if(((P1 & 0x03) != 0x03) && (key_new == 1)) {//确认按下
key_new = 0;
switch(P1 & 0x03) {
case 0x01: key_can = 1; break; //得到按键值
case 0x02: key_can = 2; break; //得到按键值
}
}
}
else //按键松开
key_new = 1;
}
void main()
{
uchar num;
P0 = P1 = P2 = P3 = 0xFF;
init_12864();
init_12864_dis();
Send_threelines(0, 0); //语音播报
while(1) {
key(); //独立按键程序
if(key_can < 20) {
if(key_can == 1) if(num < 10) num++;
if(key_can == 2) if(num != 0) num--;
if(num == 1) { //报第1个站
write_string(1,0," 66路公交车 ");
write_string(2,0," 南洛高速路口 ");
write_string(3,0," (建设路) ");
Send_threelines(1,0); //语音播报
}
else if(num == 2) { //报第2个站
write_string(1,0," 66路公交车 ");
write_string(2,0," 蓝湾新城小区 ");
write_string(3,0," (朱砂洞) ");
Send_threelines(2,0); //语音播报
}
else if(num == 3) { //报第3个站
//略
}
else if(num == 9) { //报第9个站
write_string(1,0," 66路公交车 ");
write_string(2,0," 崇文路口 ");
write_string(3,0," ");
Send_threelines(9,0); //语音播报
}
if(num == 10) { //报第10个站
write_string(1,0," 66路公交车 ");
write_string(2,0," 平顶山市卫校 ");
write_string(3,0," ");
Send_threelines(0x10,0); //语音播报
}
}
}
}
现在,已经可以编译了。
原文中,就缺少很多变量和函数。
题主应该给出全面的程序。
追问
文档里就这些啊,能帮我改一下让他能运行吗大神
追答
想要运行?
不可能。
楼主并没有给出电路、函数。
电路,都没有!
程序,你放在哪里运行?
意法半导体(中国)投资有限公司
2023-06-12 广告
2023-06-12 广告
stm32怎么样?这个问题不能一概而论,要根据您的具体情况进行分析。意法半导体单片机产品线拥有业界很宽广、极具创新力的32位产品系列 – STM32,覆盖超低功耗、超高性能方向,同时兼具很强的市场竞争力。STM32是ARM Cortex内核...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询