找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 7818|回復(fù): 8
打印 上一主題 下一主題
收起左側(cè)

求大神指導(dǎo),51初學(xué)者,想用一個(gè)按鍵控制一個(gè)數(shù)碼管,按一下加一,可就是不行

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:153645 發(fā)表于 2016-12-13 16:40 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include <REG52.H>
#define uchar unsigned char
#define uint unsigned int

sbit k1=P3^4;
sbit duan=P2^6;
sbit wei=P2^7;
uint m=0;

void delay(uint xms)
{
        uint i,j;
        for(i=xms;i>0;i--)
                for(j=112;j>0;j--);
}

void smg()
{
        uint i;
        i=m%10;
        uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
        P0=tab[i];
        duan=1;
        duan=0;
        P0=0xfe;
        wei=1;
        wei=0;
        m++;
}

void main()
{
        while(1)
        {
        if(k1==0)
        {
                delay(10);
                if(k1==0)
                {
                         while(k1!=0);
                        smg();               
                }
        }
        }       
}
//錯(cuò)誤代碼   
//按鍵控制.C(21): error C141: syntax error near 'unsigned'
//按鍵控制.C(21): error C141: syntax error near '}'
//按鍵控制.C(22): error C202: 'tab': undefined identifier

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩

相關(guān)帖子

回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:153645 發(fā)表于 2016-12-13 16:42 | 只看該作者
數(shù)碼管是共陰的
回復(fù)

使用道具 舉報(bào)

板凳
ID:154486 發(fā)表于 2016-12-13 18:32 | 只看該作者
define your 'uhar code tab[] ' at the beginning of your code
回復(fù)

使用道具 舉報(bào)

地板
ID:154486 發(fā)表于 2016-12-13 18:34 | 只看該作者
or there are somthing wrong in your synatex.....
sorry,keyborad's broken,i can not type Chinese
回復(fù)

使用道具 舉報(bào)

5#
ID:154489 發(fā)表于 2016-12-13 18:43 | 只看該作者
互相交流!
回復(fù)

使用道具 舉報(bào)

6#
ID:153645 發(fā)表于 2016-12-13 19:29 | 只看該作者
anivan 發(fā)表于 2016-12-13 18:32
define your 'uhar code tab[] ' at the beginning of your code

為什么開頭定義就可以了
回復(fù)

使用道具 舉報(bào)

7#
ID:154526 發(fā)表于 2016-12-13 20:52 | 只看該作者
#include  <reg51.h>

unsigned char code dispcount[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char i;


void  main()
{EA=1;
IT0=1;
EX0=1;



while(1)
  {P1= dispcount[i] ;
  }
}

void  ex0() interrupt  0
{
    i++;
}
回復(fù)

使用道具 舉報(bào)

8#
ID:94489 發(fā)表于 2016-12-13 21:12 | 只看該作者
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
放在開頭
回復(fù)

使用道具 舉報(bào)

9#
ID:84299 發(fā)表于 2016-12-14 22:52 | 只看該作者
慢慢來,把基礎(chǔ)學(xué)扎實(shí)點(diǎn)。
回復(fù)

使用道具 舉報(bào)

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

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

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

快速回復(fù) 返回頂部 返回列表