找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2524|回復(fù): 7
打印 上一主題 下一主題
收起左側(cè)

這段單片機程序該怎么改呢?總顯示未定義和等號旁邊語法錯誤

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:883907 發(fā)表于 2021-2-10 20:13 來自手機 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
#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;
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:744133 發(fā)表于 2021-2-11 22:37 | 只看該作者
大哥 sbit,define是關(guān)鍵字,后面要空格分開

評分

參與人數(shù) 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎勵!

查看全部評分

回復(fù)

使用道具 舉報

板凳
ID:202023 發(fā)表于 2021-2-12 23:30 | 只看該作者
sbit是關(guān)鍵字,你本意是分配io口sbit  left _m_p = P1^6; 系統(tǒng)看到sbit 就知道是干啥的,但你連寫  sbitleft_xxxxx = P1^6; 系統(tǒng)不認識。當(dāng)然編譯不通過了,define相同,另外P1^6,中的P必須大寫,若是小寫系統(tǒng)同樣不認識。

評分

參與人數(shù) 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎勵!

查看全部評分

回復(fù)

使用道具 舉報

地板
ID:155507 發(fā)表于 2021-2-13 07:47 | 只看該作者
錯誤太多
給你改了,對比一下就知道哪里錯了。

  1. #include <reg52.h>
  2. sbit Left_moto_pwm=P1^6;
  3. sbit Right_moto_pwm=P1^7;
  4. sbit Left_1_led=P1^0;
  5. sbit Left_2_led=P1^1;
  6. sbit Right_1_led=P1^2;
  7. sbit Right_2_led=P1^3;
  8. sbit P34=P3^4;
  9. sbit P35=P3^5;
  10. sbit P36=P3^5;
  11. sbit P37=P3^5;
  12. #define Left_moto_go    {P34=0;P35=1;}
  13. #define Left_moto_back  {P34=1;P35=0;}
  14. #define Left_moto_stp   {P34=1;P35=1;}
  15. #define Right_moto_go   {P36=0;P37=1;}
  16. #define Right_moto_back {P36=1;P37=0;}
  17. #define Right_moto_stp  {P36=1;P37=1;}
  18. unsigned char pwm_val_left=0; unsigned char push_val_left=0;
  19. unsigned char pwm_val_right=0; unsigned char push_val_right=0;
  20. bit Right_moto_stop=1; bit Left_moto_stop=1;
  21. unsigned int time=0;
復(fù)制代碼
回復(fù)

使用道具 舉報

5#
ID:414556 發(fā)表于 2021-2-13 17:52 | 只看該作者
直接復(fù)制粘貼的程序要仔細檢查的.
回復(fù)

使用道具 舉報

6#
ID:783421 發(fā)表于 2021-2-13 23:05 來自手機 | 只看該作者
你這個空格都沒有,是發(fā)布問題沒有認真寫還是代碼原本就沒空格?
回復(fù)

使用道具 舉報

7#
ID:115204 發(fā)表于 2021-2-14 12:35 | 只看該作者
要加空格的呀
回復(fù)

使用道具 舉報

8#
ID:949330 發(fā)表于 2021-7-5 12:32 來自手機 | 只看該作者
請問符號未定義是怎么回事呢
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表