| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 230 人关注过本帖
标题:请高手看下,这个程序要改哪里
只看楼主 加入收藏
gdxhabcde
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-2-19
收藏
 问题点数:0 回复次数:3 
请高手看下,这个程序要改哪里

                num=1
                if(sw1==1)
                    {
                    delay(5);
                    if(sw1==1)
                        {
                        while(sw4);   
                        num++;
                        if(num==5);
                        num=4;   
                        }   
                    }

            if(num==1)
                {
                out1=1;
                out2=1;
                out3=1;
                delay(100);
                }
            if(num==2)
                {
                out1=1;
                delay(100);
                }
        
            if(num==3)
                {
                out2=1;
                delay(100);
                }
        
            if(num==4)
                {
                out3=1;
                delay(100);
                }
        

不管按多少下下开关SW1后结果输出都是是out3=1;
有没人帮我看下要改哪里
2013-03-06 10:38
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
传说中的没分  还是残缺版的代码

DO IT YOURSELF !
2013-03-06 10:48
caynne
Rank: 1
等 级:新手上路
帖 子:8
专家分:1
注 册:2012-12-20
收藏
得分:0 
亲,这是按键检测吗,还是?
2013-03-06 10:56
gdxhabcde
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-2-19
收藏
得分:0 
是按键检测,写的太烂不好意思全部写上来,
我的积分为0也给不出分啊,

#include <stdio.h>
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar x,y,z;
//uchar code table[]={0x01,0x02};
int num,num1,s1num;
sbit sw1=P0^0;
sbit sw2=P0^1;
sbit sw3=P0^2;
sbit sw4=P0^3;
sbit out1=P1^0;
sbit out2=P1^1;
sbit out3=P1^2;

void delay(uint z);
void init();



void main()
{
num=0x01;
P1=0x07;
P0=0x00;
while(1)
{
if(sw1==1)   
    {   
    delay(5);
    while(sw1);
    P1=0x00;

s11:        if(sw3==1)
                {
                delay(5);
                if(sw3==1)
                    {
                    while(sw3);   
                    num--;            
                    if(num==0);
                    num=1;

                    }
                }


            if(sw4==1)
                {
                delay(5);
                if(sw4==1)
                    {
                    while(sw4);   
                    num++;
                    if(num==5);
                    num=4;   
                    }   
                }

            if(sw2==1)
                {
                delay(5);
                while(sw2);
                goto s10;
                }


            goto s11;
s10:            if(num==1)
                {
                out1=1;
                out2=1;
                out3=1;
                }
            if(num==2)
                {
                out1=1;
                }
        
            if(num==3)
                {
                out2=1;
                }
        
            if(num==4)
                {
                out3=1;
                }
        

//            if(num==5)
//                {
//            break;
//                }
    }
}
}

void delay(uint z)
{
    uint x,y;
    for(x=z;x>0;x--)
        for(y=110;y>0;y--);
}
2013-03-07 16:56
快速回复:请高手看下,这个程序要改哪里
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016527 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved