标题:
Objects\电子钟.c(73): error C141: syntax error near '='请教大佬怎么改合适
[打印本页]
作者:
王江南
时间:
2021-10-29 10:28
标题:
Objects\电子钟.c(73): error C141: syntax error near '='请教大佬怎么改合适
#include<reg52.h>
//#include<intrings.h>
#include<string.h>
#define duanxuanport = P0;
#define weixuanport = P2;
#define anjian = P3;
#define stopwatchmode 0x00;
#define timemode 0x01;
unsigned char weixuan = 0xfe;
unsigned int x = 11;
unsigned int i;
unsigned int count;
unsigned char mode = timemode;
unsigned char stopwatch_switch;
unsigned int tens_h = 0, units_h = 0, tens_min = 0, units_min = 0, tens_s = 0, units_s = 0;
unsigned char time[6] = {0,0,0,0,0,0};
unsigned char stopwatch[6] = {0,0,0,0,0,0};
unsigned int LEDcode = {
0xC0, //"0"0
0xF9, //"1"1
0xA4, //"2"2
0xB0, //"3"3
0x99, //"4"4
0x92, //"5"5
0x82, //"6"6
0xF8, //"7"7
0x80, //"8"8
0x90, //"9"9
0xFF, //¹Ø±Õ10
0xBF //'-'
};
void delay(unsigned int i)
{
unsigned int x,y;
for(x=i;x<0;x--)
{
y = 12;
while(y--);
}
}
void timer0_init()
{
TMOD = 0x01;
TH0 = 0x4b;
TL0 = 0xfd;
IT0 = 0;
ET0 = 1;
TR0 = 1;
EA = 1;
}
void timer1_init()
{
TMOD|=0x10;
TH1 = 0x4b;
TL1 = 0xfd;
TR1 = 0;
}
void LEDplayer(unsigned char tens_h ,units_h,tens_min,units_min,tens_s,units_s)
{
weixuan = 0xfe;
duanxuanport = LEDcode[tens_h];
weixuan = _cror_(weixuan,1);
weixuanport = weixuan;
delay(3);
weixuanport = 0xff;
duanxuanport = LEDcode[10];
duanxuanport = LEDcode[units_h];
weixuan = _cror_(weixuan,1);
weixuanport = weixuan;
delay(3);
weixuanport = 0xff;
duanxuanport = LEDcode[10];
duanxuanport = LEDcode[tens_min];
weixuan = _cror_(weixuan,1);
weixuanport = weixuan;
delay(3);
weixuanport = 0xff;
duanxuanport = LEDcode[10];
duanxuanport = LEDcode[units_min];
weixuan = _cror_(weixuan,1);
weixuanport = weixuan;
delay(3);
weixuanport = 0xff;
duanxuanport = LEDcode[10];
duanxuanport = LEDcode[tens_s];
weixuan = _cror_(weixuan,1);
weixuanport = weixuan;
delay(3);
weixuanport = 0xff;
duanxuanport = LEDcode[10];
}
复制代码
作者:
stycx
时间:
2021-10-31 10:26
你这是来考语法的吗
02行 打多一个s
#define 后边不需要 等号 跟分号
26行 是数组 unsigned int LEDcode[]
所以,前边按这个修改就可以
#include<reg51.h>
#include<intrins.h>
#include<string.h>
#define duanxuanport P0
#define weixuanport P2
#define anjian P3
#define stopwatchmode 0x00
#define timemode 0x01
unsigned char weixuan = 0xfe;
unsigned int x = 11;
unsigned int i;
unsigned int count;
unsigned char mode = timemode;
unsigned char stopwatch_switch;
unsigned int tens_h = 0, units_h = 0, tens_min = 0, units_min = 0, tens_s = 0, units_s = 0;
unsigned char time[6] = {0,0,0,0,0,0};
unsigned char stopwatch[6] = {0,0,0,0,0,0};
unsigned int LEDcode[12] = {
0xC0, //"0"0
0xF9, //"1"1
0xA4, //"2"2
0xB0, //"3"3
0x99, //"4"4
0x92, //"5"5
0x82, //"6"6
0xF8, //"7"7
0x80, //"8"8
0x90, //"9"9
0xFF, //1?±?10
0xBF //'-'
};
作者:
stycx
时间:
2021-10-31 10:30
上修改后的代码吧 自己对照一下
code.zip
2021-10-31 10:30 上传
点击文件名下载附件
745 Bytes, 下载次数: 2
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1