標(biāo)題:
這段單片機(jī)程序該怎么改呢?總顯示未定義和等號旁邊語法錯(cuò)誤
[打印本頁]
作者:
2640234646
時(shí)間:
2021-2-10 20:13
標(biāo)題:
這段單片機(jī)程序該怎么改呢?總顯示未定義和等號旁邊語法錯(cuò)誤
#include<reg52.h>
sbitLeft_moto_pwm=P1^6;
sbitRight_moto_pwm=P1^7;
sbitLeft_1_led=P1^0;
sbitLeft_2_led=P1^1;
sbitRight_1_led=P1^2;
sbitRight_2_led=P1^3;
#defineLeft_moto_go{P3^4=0,P3^5=1;}
#defineLeft_moto_back{P3^4=1,P3^5=0;}
#defineLeft_moto_stp{P3^4=1,P3^5=1;}
#defineRight_moto_go{P3^6=0,P3^7=1;}
#defineRight_moto_back{P3^6=1,P3^7=0;}
#defineRight_moto_stp{P3^6=1,P3^7=1;}
unsigned char pwm_val_left=0; unsigned char push_val_left=0;
unsigned char pwm_val_right=0; unsigned char push_val_right=0;
bit Right_moto_stop=1;bit Left_moto_stop=1;
unsigned int time=0;
作者:
xiao1miao3
時(shí)間:
2021-2-11 22:37
大哥 sbit,define是關(guān)鍵字,后面要空格分開
作者:
huaruolong
時(shí)間:
2021-2-12 23:30
sbit是關(guān)鍵字,你本意是分配io口sbit left _m_p = P1^6; 系統(tǒng)看到sbit 就知道是干啥的,但你連寫 sbitleft_xxxxx = P1^6; 系統(tǒng)不認(rèn)識。當(dāng)然編譯不通過了,define相同,另外P1^6,中的P必須大寫,若是小寫系統(tǒng)同樣不認(rèn)識。
作者:
angmall
時(shí)間:
2021-2-13 07:47
錯(cuò)誤太多
給你改了,對比一下就知道哪里錯(cuò)了。
#include <reg52.h>
sbit Left_moto_pwm=P1^6;
sbit Right_moto_pwm=P1^7;
sbit Left_1_led=P1^0;
sbit Left_2_led=P1^1;
sbit Right_1_led=P1^2;
sbit Right_2_led=P1^3;
sbit P34=P3^4;
sbit P35=P3^5;
sbit P36=P3^5;
sbit P37=P3^5;
#define Left_moto_go {P34=0;P35=1;}
#define Left_moto_back {P34=1;P35=0;}
#define Left_moto_stp {P34=1;P35=1;}
#define Right_moto_go {P36=0;P37=1;}
#define Right_moto_back {P36=1;P37=0;}
#define Right_moto_stp {P36=1;P37=1;}
unsigned char pwm_val_left=0; unsigned char push_val_left=0;
unsigned char pwm_val_right=0; unsigned char push_val_right=0;
bit Right_moto_stop=1; bit Left_moto_stop=1;
unsigned int time=0;
復(fù)制代碼
作者:
amandv
時(shí)間:
2021-2-13 17:52
直接復(fù)制粘貼的程序要仔細(xì)檢查的.
作者:
繞指的柔
時(shí)間:
2021-2-13 23:05
你這個(gè)空格都沒有,是發(fā)布問題沒有認(rèn)真寫還是代碼原本就沒空格?
作者:
justinchill
時(shí)間:
2021-2-14 12:35
要加空格的呀
作者:
獨(dú)小獸
時(shí)間:
2021-7-5 12:32
請問符號未定義是怎么回事呢
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1