| #include<reg52.h> unsigned char zkbl;//左占空比 unsigned char zkbr;//右占空比 unsigned char pwm_t;//周期 sbit motor1_1=P0^0; sbit motor1_2=P0^1; sbit motor2_1=P0^2; sbit motor2_2=P0^3; sbit xj1=P0^4; sbit xj2=P0^5; void forward(); void left(); void right(); void main() { while(1) { if (xj1==0&&xj2==0) forward();//直行 else if (xj1==0&&xj2==1) left();//左轉 else(xj1==1&&xj2==0) right();//右轉 } } void forward() { motor1_1=1; motor1_2=0; motor2_1=1; motor2_2=0; } void left() { motor1_1=0; motor1_2=0; motor2_1=1; motor2_2=0; } void right() { motor1_1=1; motor1_2=0; motor2_1=0; motor2_2=0; } Killer Queen.c(25): error C141: syntax error near 'right' 沒看懂咋回事,,,, 一個還沒完成的小車程序,先把電機和循跡給試著寫了寫 |
lyxing 發表于 2020-1-25 10:39
else(xj1==1&&xj2==0) 改為 else if (xj1==1&&xj2==0) 試試
hhggg 發表于 2020-1-25 12:14
else有條件判斷要加 if

lyxing 發表于 2020-1-25 14:49
Killer 設置問題吧。output有一個建立HEX文件選項。打上勾。
| 歡迎光臨 (http://m.raoushi.com/bbs/) | Powered by Discuz! X3.1 |