按键精灵运行没反应点了没反应啊,有没有大神教我

查看: 111|回复: 0
单片机按键按着没反应,各位大神来帮看看
实现功能:
上电自检,数码管 LED 全亮, 3 秒钟后黑屏,然后蜂鸣器响 200mS;
2 按键 S4,显示学号后四位;(15 分)
3 按下 S5, 测温,即显示当前温度;
再次按下 S5,将温度显示为华氏温度。(25 分)
4 按下 S6,存储当前温度;(15 分)
5 按下 S7,显示存储温度;再次按下 S7,将温度显示为华氏温度。&&
卡在写按键很久了,不知道哪有逻辑问题,大神帮忙看看
单片机源程序如下:
#include&STC15F2K60S2.H&
#include&onewire.h&
#define uchar unsigned char
#define uint unsigned int& && &
& && && && && &&&//&&0& & 1& & 2& & 3& & 4& & 5& & 6& & 7& & 8& & 9& & .& &a& &&&b& & c& & d& & e& &f& &熄灭
uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x7f,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xFF};
uchar yi,er,san,si,wu ,liu,qi,ba,temp,b;
int num=600;int nun=640;
int ducunwendu[];
void delayms(int ms);
void allinit();
int keycan();
void Timer0Init(void);
void display1(uchar yi,uchar er);
void display2(uchar san,uchar si);
void display3(uchar wu,uchar liu);
void display4(uchar qi,uchar ba);
void main()
{
& && &
& && &&&allinit();
& && &&&P0=0X00;
& && &&&P2=0X80;
& && &&&P0=0X00;
& && &
& && && && && && && && && && &&&Timer0Init();
& && &
& && &&&while(1)
& && &&&{
& && && && && & keycan();
& && && && && & x=keycan();
& && && && && & if(x==1)
& && && && && & {
& && && && && && && &&&
& && && && && && && &&&
& && && && && & }
& && && && && & else if(x==2)
& && && && && & {
& && && && && && && &&&
& && && && && && && &&&
& && && && && & }
& && && && && && && && &else if(x==3)
& && && && && & {
& && && && &b++;
& && && && && && && && &if(b==1)
& && && && && && && && &{yi=17;er=17;san=17;si=17;wu=17;
& && && && && && && && &wendu=rd_temperature_f();
& && && && && && && &&&
& && && && && && & wu=(int)(wendu/10)%10;
& && && && & liu=(int)wendu%10;
& && && && && && && && &P2=0XFF;
& && && && && && && &&&
& && && && && && && &&&
& && && && && && & qi=(int)(wendu*10)%10;
& && && && && && && &&&
& && && && && && &&&ba= 13;
& && && && && && && &&&
& && && && && && &&&display1(yi,er);
& && && && && && &&&display2(san,si);
& && && && && && &&&display3(wu,liu);
& && && && && && && && &&&display3(wu,10);
& && &&&display4(qi,ba);}
& && && && && && && && && && &
& && && && && && && && &if(b==2)
& && && && && && && && &{
& && && && && && && && && && &&&yi=17;er=17;san=17;si=17;wu=17;
& && && && && && && && &wendu=rd_temperature_f();
& && && && && && && && &huashi=wendu*1.8+32;
& && && && && && & wu=(int)(huashi/10)%10;
& && && && & liu=(int)huashi%10;
& && && && && && && && &P2=0XFF;
& && && && && && && &&&
& && && && && && && &&&
& && && && && && & qi=(int)(huashi*10)%10;
& && && && && && && &&&
& && && && && && &&&ba= 13;
& && && && && && && &&&
& && && && && && &&&display1(yi,er);
& && && && && && &&&display2(san,si);
& && && && && && &&&display3(wu,liu);
& && && && && && && && &&&display3(wu,10);
& && &&&display4(qi,ba);
& && && && && && && && && && &&&b=0;
& && && && && && && && &}
& && &
& && && && && &
& && && && && && && &&&
& && && && && && && &&&
& && && && && &
& && && && && && && &&&
& && && && && & }
& && && && && & else if(x==4)
& && && && && & {yi=17;er=17;san=17;si=17;
& && && && && && && && &wu=8;liu=0;qi=3;ba=4;
& && && && && && && && &display1(yi,er);
& && && && && & display2(san,si);
& && && && && & display3(wu,liu);
& && && && && & display4(qi,ba);
& && && && && & }
& && && && && &
& && &&&}
}
void delayms(int ms)
{
& && &&&int i,j;
& && &&&for(i=i&0;i--)
& && && && && & for(j=845;j&0;j--);
}
void allinit()
{
& && &&&P2=0XA0;
& && &&&P0=0X00;//关闭蜂鸣器,继电器
& && &
& && &&&P2=0X80;
& && &&&P0=0XFF;//关闭LED灯
& && &
& && &&&P2=0XC0;
& && &&&P0=0XFF;//选择所有数码管
& && &&&P2=0XFF;
& && &&&P0=0XFF;//关闭所有数码管
}
void display1(uchar yi,uchar er)
{
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X01;//选择第一个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[yi];
& && && && && & delayms(1);
& && && && && &
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X02;//选择第二个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[er];
& && && && && & delayms(1);
}& && &
void display2(uchar san,uchar si)
{
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X04;//选择第三个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[san];
& && && && && & delayms(1);
& && && && && &
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X08;//选择第四个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[si];
& && && && && & delayms(1);
}
void display3(uchar wu,uchar liu)
{
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X10;//选择第一个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[wu];
& && && && && & delayms(1);
& && && && && &
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X20;//选择第一个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[liu];
& && && && && & delayms(1);
}
void display4(uchar qi,uchar ba)
{
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X40;//选择第一个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[qi];
& && && && && & delayms(1);
& && && && && &
& && && && && & P2=0XC0;//打开位选573& &U8
& && && && && & P0=0X80;//选择第一个数码管
& && && && && & P2=0XFF;//打开段选573& &U7
& && && && && & P0=tab[ba];
& && && && && & delayms(1);
}
void Timer0Init(void)& && && && && & //5毫秒@11.0592MHz
{
& && &&&AUXR |= 0x80;& && && && && & //定时器时钟1T模式
& && &&&TMOD &= 0xF0;& && && && && & //设置定时器模式
& && &&&TL0 = 0x00;& && && && && & //设置定时初值
& && &&&TH0 = 0x28;& && && && && & //设置定时初值
& && &&&TF0 = 0;& && && && && & //清除TF0标志
& && &&&TR0 = 1;
EA=1;
ET0=1;& && &&&//定时器0开始计时
}
void Timer0() interrupt 1
{
& && &&&num--;
nun--;
& && &&&if(num==0)
& && &&&{
& && &
& && && && && & P0=0XFF;
& && && && && & P2=0XFF;
& && && && && & P0=0XFF;
& && && && && & P2=0XA0;
& && && && && & P0=0X40;
& && &&&}
& && &&&if(nun==0)
& && &&&{P0=0X00;}
}
int keycan()
{int s1=0;
& && &&&P3=0x7f;P4=0
& && &&&temp=P3;
& && &&&if(P3!=0x7f)
& && &&&{
& && && && && & delayms(5);
& && && && && & temp=P3;
& && && && && & if(P3!=0x7f)
& && && && && & {
& && && && && && && && &switch(temp)
& && && && && && && && &{
& && && && && && && && && && &&&case 0x7e : s1=1;
& && && && && && && && && && &&&case 0x7d : s1=2;
& && && && && && && && && && &&&case 0x7b : s1=3;
& && && && && && && && && && &&&case 0x77 : s1=4;
& && && && && && && && &}
& && && && && && && && &while(temp!=0x7f)
& && && && && && && && &{
& && && && && && && && && && &&&temp=P3;
& && && && && && && && && && &&&delayms(5);
& && && && && && && && &}
& && && && && & }
& && &&&}
& && &&&return s1;
}复制代码
回帖助人的奖励!
无效楼层,该帖已经被删除
Powered by急!!大神,我想问个问题,如何用按键控制步进电机正反转,我自己编了条程序,还请大神帮忙看看为什么按键控制没用,非常感谢!!! - TM4C 微控制器 - 德州仪器在线技术支持社区
急!!大神,我想问个问题,如何用按键控制步进电机正反转,我自己编了条程序,还请大神帮忙看看为什么按键控制没用,非常感谢!!!
发表于3年前
<input type="hidden" id="hGroupID" value="41"
&p>#ifndef PART_&a href=&http://www.ti.com.cn/product/cn/TM4C123GH6PM& target=&extwin&>TM4C123GH6PM&/a>&br>#define PART_&a href=&http://www.ti.com.cn/product/cn/TM4C123GH6PM& target=&extwin&>TM4C123GH6PM&/a>&br>#endif&/p>
&p>#include &stdbool.h&&br>#include &stdint.h&&br>#include &stdio.h&&br>#include &inc\&a href=&http://www.ti.com.cn/product/cn/tm4c123gh6pm& target=&extwin&>tm4c123gh6pm&/a>.h&&br>#include &driverlib/ssi.h&&br>#include &driverlib/rom.h&&br>#include &inc/hw_memmap.h&&br>#include &driverlib/gpio.h&&br>#include &driverlib/sysctl.h&&/p>
&p>#define data GPIO_PORTB_AHB_DATA_R&/p>
&p>unsigned int i,j,k;&br>unsigned int N=512;&br>unsigned char eight_pos[8]={0x06,0x07,0x03,0x0b,0x09,0x0d,0x0c,0x0e}; /*八拍驱动正转*/&br>unsigned char eight_rev[8]={0x0e,0x0c,0x0d,0x09,0x0b,0x03,0x07,0x06}; /*八拍驱动正转*/&br>void delay(unsigned int z);&br>void m_eight_pos();&br>void m_eight_rev();&/p>
&p>&br>int main(void)&br>{&/p>
&p>SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);&/p>
&p>SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);&/p>
&p>GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3 );&/p>
&p>GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3);&/p>
&p>&br>while(1)&br>{&/p>
&p>if((GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_2 ))==0)&br>{&br>m_eight_pos(); //八拍驱动正转360度&br>}&br>// delay(200);&/p>
&p>else if((GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_3))==0)&br>{&br>m_eight_rev(); //八拍驱动反转360度&br>}&br>// delay(200);&/p>
&p>}&br>void delay(unsigned int z) /*延时z毫秒*/&br>{&br>unsigned int x,y;&br>for(x=z;x&0;x--)&br>for(y=110;y&0;y--) ;&br>}&br>/******************************八拍驱动正转 (N*22.5/32)*************************************/&br>void m_eight_pos()&br>{&br>for(k=0;k&N;k++)&br>{&/p>
&p>for(i=0;i&8;i++) //八拍一个脉冲转子转动5.625/2度,八拍共 22.5度&/p>
&p>{&br>GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0 | GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3,(eight_pos[i]&0x01)|(eight_pos[i]&0x02)|(eight_pos[i]&0x04)|(eight_pos[i]&0x08));&/p>
&p>delay(20);&br>}&/p>
&p>&br>}&br>}&br>/******************************八拍驱动反转 (N*22.5/32)*************************************/&br>void m_eight_rev()&br>{&br>for(k=0;k&N;k++)&br>{&/p>
&p>for(i=0;i&8;i++) //八拍一个脉冲转子转动5.625/2度,八拍共22.5度&/p>
&p>{&br>GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0 | GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3,(eight_rev[i]&0x01)|(eight_rev[i]&0x02)|(eight_rev[i]&0x04)|(eight_rev[i]&0x08));&br>delay(20);&br>}&br>}&br>}&/p>&div style=&clear:&>&/div>" />
急!!大神,我想问个问题,如何用按键控制步进电机正反转,我自己编了条程序,还请大神帮忙看看为什么按键控制没用,非常感谢!!!
此问题尚无答案
All Replies
#ifndef PART_#define PART_#endif
#include &stdbool.h&#include &stdint.h&#include &stdio.h&#include &inc\.h&#include &driverlib/ssi.h&#include &driverlib/rom.h&#include &inc/hw_memmap.h&#include &driverlib/gpio.h&#include &driverlib/sysctl.h&
#define data GPIO_PORTB_AHB_DATA_R
unsigned int i,j,k;unsigned int N=512;unsigned char eight_pos[8]={0x06,0x07,0x03,0x0b,0x09,0x0d,0x0c,0x0e}; /*八拍驱动正转*/unsigned char eight_rev[8]={0x0e,0x0c,0x0d,0x09,0x0b,0x03,0x07,0x06}; /*八拍驱动正转*/void delay(unsigned int z);void m_eight_pos();void m_eight_rev();
int main(void){
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3 );
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3);
if((GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_2 ))==0){m_eight_pos(); //八拍驱动正转360度}// delay(200);
else if((GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_3))==0){m_eight_rev(); //八拍驱动反转360度}// delay(200);
}void delay(unsigned int z) /*延时z毫秒*/{unsigned int x,y;for(x=z;x&0;x--)for(y=110;y&0;y--) ;}/******************************八拍驱动正转 (N*22.5/32)*************************************/void m_eight_pos(){for(k=0;k&N;k++){
for(i=0;i&8;i++) //八拍一个脉冲转子转动5.625/2度,八拍共 22.5度
{GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0 | GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3,(eight_pos[i]&0x01)|(eight_pos[i]&0x02)|(eight_pos[i]&0x04)|(eight_pos[i]&0x08));
delay(20);}
}}/******************************八拍驱动反转 (N*22.5/32)*************************************/void m_eight_rev(){for(k=0;k&N;k++){
for(i=0;i&8;i++) //八拍一个脉冲转子转动5.625/2度,八拍共22.5度
{GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_0 | GPIO_PIN_1|GPIO_PIN_2 |GPIO_PIN_3,(eight_rev[i]&0x01)|(eight_rev[i]&0x02)|(eight_rev[i]&0x04)|(eight_rev[i]&0x08));delay(20);}}}
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
状元42995分
d电机正反转51的程序已经很多了,你移植一个过来即可,有两点需要注意
1.确保可以驱动电机,电机驱动芯片是否接好
2.电机的时序是否正确
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
探花13962分
建议分开调试,先把M4的相关外设都调试正常了,然后再加入电机控制部分的逻辑。这样有问题也好定位。
如果答案回答了您的问题,请确认答案,谢谢!:)
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
不用按键控制时,直接用延时是可以实现步进电机正反转,就是对按键判断部分不对,大神看我这判断条件可不可以这么写
if((GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_2 ))==0){m_eight_pos(); //八拍驱动正转360度}
else if((GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_3))==0){m_eight_rev(); //八拍驱动反转360度}
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
探花13962分
楼主按键都没去抖动啊,这一按下去都不知道跳哪里去了。
如果答案回答了您的问题,请确认答案,谢谢!:)
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
h一定得去抖吗?我一直按着也没用,判断条件是对的吧?我试试去抖看看,谢了啊
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
探花13962分
按键都要去抖的。先把这个做了,然后再看你的执行函数的逻辑和预期是否能符合。
是按下执行一次,还是按下一直执行。
如果答案回答了您的问题,请确认答案,谢谢!:)
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
可以了,这个程序现在能实现,之前不知道为什么,没有加去抖
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
探花13962分
按键都要加去抖的嘛,你量一下按键得波形,按下和抬起的时候,都会高低电平跳好多次,不去抖就全乱了。
如果答案回答了您的问题,请确认答案,谢谢!:)
You have posted to a forum that requires a moderator to approve posts before they are publicly available.各位大神,有没有用易语言大漠按键多线程教程或源码啊 - 『悬赏问答区』
- 吾爱破解 - LCG - LSG |安卓破解|病毒分析|破解软件|www.52pojie.cn
后使用快捷导航没有帐号?
只需一步,快速开始
请完成以下验证码
请完成以下验证码
查看: 3145|回复: 6
各位大神,有没有用易语言大漠按键多线程教程或源码啊
阅读权限10
各位大神,有没有用易语言大漠按键多线程教程或源码啊? 最好是用魔鬼作坊写的源码,当然其他的也可以,教程也好,谢谢谢谢谢谢
写脚本最好用TC 脚本语言,
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
阅读权限10
写脚本最好用TC 脚本语言,&&方便快捷,
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
阅读权限30
把你签名的片子发一下,嘎嘎,
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
阅读权限10
把你签名的片子发一下,嘎嘎,
卧槽,我也偷了别人的来装,我只求名字就行,求草liu网求激活码,
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
阅读权限10
写脚本最好用TC 脚本语言,&&方便快捷,
TC写活动辅助软件怎么样?
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
阅读权限10
TC写活动辅助软件怎么样?
TC线程比较好, 操作又方便, 其他的因人而异了,
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
阅读权限10
TC线程比较好, 操作又方便, 其他的因人而异了,
O(∩_∩)O谢谢
发帖求助前要善用【】功能,那里可能会有你要找的答案;如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子分类或者标题加上【已解决】;如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心】和【CB】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
免责声明:吾爱破解所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。
( 京ICP备号 | 京公网安备 87号 )
Powered by Discuz!
Comsenz Inc.蠢蠢按键为什么我用不了啊。有没有大神帮我解决一下啊!-交流广场-剑网3PVE官方站(JX3PVE.COM)
我是W8系统。笔记本的。没有外接键盘。别人都能用。为什么我就用不了啊。360什么的我都设置了
点击开关回复楼层
兼容性问题,尝试下别的
是要我尝试用别的按键吗。别的我也试过了。也用不了。有没有办法处理下这个兼容性啊
你的键盘是不是USB接口
换一个用吧,蠢蠢按键我用了电脑直接蓝屏,也不造为什么,反正就是用不了,现在用的极简按键,感觉还不错
极简按键是什么啊,在哪里下载的啊,分享一个吧。QQ
没有更多了
试一试@用户名 立即召唤神龙 小伙伴会收到通知喔:)无需加好友即可通知到
只要你是女生,即可申请
玄晶的庇佑
有了玄晶的庇佑,打团出大铁几率增加8%
在线时间大于100即可领取
即可享有众多特权,免下载限制。
本附件需要回复可见,回复后需要刷新页面。
您当前使用的浏览器版本过低,网站部分功能可能失效,请更换合适的浏览器。

我要回帖

更多关于 荒野行动pc按键没反应 的文章

 

随机推荐