找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2149|回复: 3
打印 上一主题 下一主题
收起左侧

各位大师。。帮我看哈程序那里出错了。谢谢了。。

[复制链接]
跳转到指定楼层
楼主
ID:52706 发表于 2013-8-6 18:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
数码管位选码能不能用编码的形式表示,我这个程序很多错误,请大师指教。
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit wela=P2^7;
sbit dula=P2^6;

uchar a,b;

uchar code dulama[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f};//共阴数码管段选编码
uchar code welama[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf}//数码管的位选
void main()
{
        TMOD=0x01;
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        EA=1;
        ET0=1;
        TR0=1;
        while(1)
        {
                if(a==20)
                        a=0;
                for(b=0;b<10;b++)
                {       
                        wela=1;
                        P0=welama[b];
                        wela=0;
                        dula=1;
                        P0=dulama[b];
                        dula=0;
                               
                }
               

        }
}
void To_time() interrupt 1
{

        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        a++;
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:52955 发表于 2013-8-12 09:27 | 只看该作者
你这个连接几个数码管啊 ?还有段选和位选连到一个端口上了,P2^7这些引脚只能是高和低2种电平
回复

使用道具 举报

板凳
ID:52066 发表于 2013-8-16 15:40 | 只看该作者
你位选和编码没错的话,这样看行不:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit wela=P2^7;
sbit dula=P2^6;

uchar a,b,c;

uchar code dulama[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f};//共阴数码管段选编码
uchar code welama[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf}//数码管的位选
void main()
{
        TMOD=0x01;
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        EA=1;
        ET0=1;
        TR0=1;
        while(1)
        {
                if(a==20)
                {
                      if(b==10)
                          b=0;
                      if(c==6)
                          c=0;
                      a=0;
                      wela=1;
                      P0=welama[c];
                      wela=0;
                      dula=1;
                      P0=dulama[b];
                      dula=0;
                      b++;
                      c++;
                }
               

        }
}
void To_time() interrupt 1
{

        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        a++;
}
       
回复

使用道具 举报

地板
ID:76287 发表于 2015-4-10 09:14 | 只看该作者
虽然不懂,但还是要顶,毕竟每一位老手都是从新手蜕变而来的,赞一个。。。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表