找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2494|回復: 9
收起左側

新人提問 能幫我看看 獨立鍵盤 控制 流水燈開關的程序

[復制鏈接]
ID:229724 發(fā)表于 2017-8-28 17:02 來自觸屏版 | 顯示全部樓層 |閱讀模式
硬件沒有問題,程序能生成hex文件,但為什么我按下鍵盤時燈沒有亮?
image.jpg
回復

使用道具 舉報

ID:229724 發(fā)表于 2017-8-28 17:22 來自觸屏版 | 顯示全部樓層
重新照了
image.jpg
回復

使用道具 舉報

ID:229724 發(fā)表于 2017-8-28 17:27 | 顯示全部樓層
#include "reg52.h"                         
#include "intrins.h"

typedef unsigned int u16;


#define uint unsigned int
#define uchar unsigned char

void delayms(uint);
uchar aa;

sbit k1=P3^1;                 

void delay(u16 i)
{
        while(i--);       
}
void keypros()
{
        if(k1==0)                 
        {       
                delay(10);   
                if(k1==0)       
                {
                        aa=0xfe;
                        while(1)
                        {
                                P1=aa;
                                delayms(500);
                                aa=_crol_(aa,1);
                        }         
                }
                while(!k1);         
        }               
}
void delayms(uint xms)
{
        uint  i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);
}
回復

使用道具 舉報

ID:190832 發(fā)表于 2017-8-28 17:51 | 顯示全部樓層
你這寫的什么爛程序,連個主函數(shù)都沒有,程序怎么可能執(zhí)行???哪有你這樣在子函數(shù)while(1)的。建議你先學一下C語言的基本語法。
回復

使用道具 舉報

ID:151348 發(fā)表于 2017-8-28 18:08 | 顯示全部樓層
這個圖看起來好難受,下次直接粘貼程序
你這程序沒有main函數(shù)
回復

使用道具 舉報

ID:229724 發(fā)表于 2017-8-28 22:45 來自觸屏版 | 顯示全部樓層
hange_v 發(fā)表于 2017-8-28 17:51
你這寫的什么爛程序,連個主函數(shù)都沒有,程序怎么可能執(zhí)行???哪有你這樣在子函數(shù)while(1)的。建議你先學 ...

好的,謝謝
回復

使用道具 舉報

ID:229724 發(fā)表于 2017-8-28 22:46 來自觸屏版 | 顯示全部樓層
imxuheng 發(fā)表于 2017-8-28 18:08
這個圖看起來好難受,下次直接粘貼程序
你這程序沒有main函數(shù)

好的,謝謝
回復

使用道具 舉報

ID:105206 發(fā)表于 2017-8-29 09:06 | 顯示全部樓層
#include "reg52.h"                        
#include "intrins.h"

typedef unsigned int u16;


#define uint unsigned int
#define uchar unsigned char

void delayms(uint);
uchar aa;

sbit k1=P3^1;                 

void delay(u16 i)
{
        while(i--);        
}

void delayms(uint xms)
{
        uint  i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);
}
int main()
{
        if(k1==0)                 
        {        
                delayms(10);   
                if(k1==0)        
                {
                       while(!k1);  
                        aa=0xfe;
                        while(1)
                        {
                                P1=aa;
                                delayms(500);
                                aa=_crol_(aa,1);
                        }         
                }
                     
        }               
}
回復

使用道具 舉報

ID:220342 發(fā)表于 2017-8-29 11:37 | 顯示全部樓層
樓主還是先去學下C語言的規(guī)則,再寫,主函數(shù)不是寫成 int main()的,改為void main()。另外如果你初學,先寫個簡單的,從點亮第一個LED練起。
回復

使用道具 舉報

ID:229884 發(fā)表于 2017-8-29 15:57 | 顯示全部樓層
缺少主函數(shù)(main)
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表