欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
51單片機加減程序運行錯誤,求幫助
[打印本頁]
作者:
檸玖
時間:
2021-11-2 21:53
標題:
51單片機加減程序運行錯誤,求幫助
我寫的是0~9的加減,從0~9的加法是可行的。
但是按下s4就直接回到0了。沒有減下去請問大佬們我哪里寫錯了嗎
單片機源程序如下:
#include <reg51.h>
sbit s2=P3^0;
sbit s3=P3^1;
sbit s4=P3^2;
sbit we=P2^7;
sbit du=P2^6;
char code m[]={0x3f,0x06,0x5b,0x4f,0x66,0xdf6d,0x7d,0x07,0x7f,0x77};
int c=0;
void ys(int a)
{
int i,j;
for(i=0;i<a;i++)
for(j=0;j<a;j++);
}
void main()
{
while(1)
{
we=1;
P0=0xfe;
we=0;
if(s2==0)
{
ys(10);
if(s2==0)
{
du=1;
P0=0x00;
du=0;
ys(200);
}
}
if(s3==0)
{
ys(20);
if(s3==0)
{
if(c<9)
{
c++;
du=1;
P0=m[c];
du=0;
ys(200);
}
}
}
if(s4==0)
{
ys(20);
if(s4==0)
{
if(c>0)
{
c--;
du=1;
P0=m[c];
du=0;
ys(200);
}
}
}
}
}
復制代碼
作者:
wulin
時間:
2021-11-3 06:25
#include <reg51.h>
sbit s2=P3^0;
sbit s3=P3^1;
sbit s4=P3^2;
sbit we=P2^7;
sbit du=P2^6;
char code m[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int c=0;
void ys(int a)
{
int i,j;
for(i=0;i<a;i++)
for(j=0;j<110;j++);
}
void main()
{
du=1;
P0=m[c];
du=0;
ys(10);
while(1)
{
we=1;
P0=0xfe;
we=0;
if(s2==0)
{
ys(10);
if(s2==0)
{
du=1;
P0=0x00;
du=0;
while(s2==0);
}
}
if(s3==0)
{
ys(20);
if(s3==0)
{
if(c<9)
{
c++;
du=1;
P0=m[c];
du=0;
while(s3==0);
}
}
}
if(s4==0)
{
ys(20);
if(s4==0)
{
if(c>0)
{
c--;
du=1;
P0=m[c];
du=0;
while(s4==0);
}
}
}
}
}
復制代碼
作者:
xianfajushi
時間:
2021-11-3 06:46
https://blog.csdn.net/xianfajushi/article/details/80885105
作者:
weijoyer
時間:
2021-11-3 08:07
你搞個按鍵松開檢測,你按著按鍵會一直加
作者:
13205495918
時間:
2021-11-3 08:19
是不是你的按鍵時間的問題,雖然只摁一下,但是對于單片機來說已經(jīng)運算了好幾次減法的程序
作者:
累不死的狗
時間:
2021-11-3 21:54
加一個松手檢測試一下
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1