找回密码
 立即注册

QQ登录

只需一步,快速开始

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

一个声控流水灯的程序,有一处错误,不过找不出来,求大神帮帮

[复制链接]
跳转到指定楼层
楼主
#include<reg51.h>
unsigned char uchar;
unsigned int uint;
#define led P1;
sbit voice=P2^4;
uchar tab1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar tab2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar tab3[]={0xe7,0xdb,0xbd,0x7e};
uchar tab4[]={0x7e,0xbd,0xdb,0xe7};
uchar he [4] = {0,0,0,0};
uchar num=0;
uchar counter=0;
uchar counter1=0;
bit flag=0;
bit flag1=0;
void delay1m(uint x)
{
uint i,j;
for(i=0;i<x;i++)
for(j=0;j<120;j++)
}
void time0_time1_init()
{
TMOD=0x11;
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
TR0=0;
ET1=ET0=TR1=EA=1;
}
void main()
{
time0_time1_init();
delay1m(2000);
while(1)
{
if(!flag1)
{
if(!voice)
{
num++;flag1=1;
he[0]=he[1]=he[2]=he[3]=0;
if(num>=5){num=0;}
TR0=1;
}
}
}



编译结果:

compiling 声控流水灯.c...
声控流水灯.c(3): warning C317: attempt to redefine macro 'unsigned'
声控流水灯.c(6): error C129: missing ';' before 'tab1'
Target not created

e417f8edab64034fafa3908aa9c379310b551d38.jpg (26.65 KB, 下载次数: 79)

e417f8edab64034fafa3908aa9c379310b551d38.jpg
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:167113 发表于 2017-3-3 13:40 | 只看该作者
#define unsigned char uchar;这样吧
回复

使用道具 举报

板凳
ID:146949 发表于 2017-3-3 16:46 | 只看该作者
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
#define led P1;
sbit voice=P2^4;
uchar tab1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar tab2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar tab3[]={0xe7,0xdb,0xbd,0x7e};
uchar tab4[]={0x7e,0xbd,0xdb,0xe7};
uchar he[4] = {0,0,0,0};
uchar num=0;
uchar counter=0;
uchar counter1=0;
bit flag=0;
bit flag1=0;
void delay1m(uint x)
{
uint i,j;
for(i=0;i<x;i++)
for(j=0;j<120;j++);
}
void time0_time1_init()
{
TMOD=0x11;
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
TR0=0;
ET1=ET0=TR1=EA=1;
}
void main()
{
        time0_time1_init();
        delay1m(2000);
        while(1)
        {
                if(!flag1)
                        {
                        if(!voice)
                                {
                                        num++;flag1=1;
                                        //e[0]=he[1]=he[2]=he[3]=0;
                                        if(num>=5){num=0;}
                                        TR0=1;
                                }
                        }
        }
}
回复

使用道具 举报

地板
ID:165498 发表于 2017-3-6 10:40 | 只看该作者
wosiyabo 发表于 2017-3-3 16:46
#include
#define uchar unsigned char
#define uint unsigned int

谢谢!!!!!
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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