欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 6346|回復: 2
打印 上一主題 下一主題
收起左側

自己寫的一個人藍牙Arduino小車程序源碼

[復制鏈接]
跳轉到指定樓層
樓主
自己寫的一個人藍牙Arduino小車,附件有藍牙串口助手


Arduino源程序如下:
  1. //因為數字端口2和13未被占用,所以我們就要2和13端口來接超聲波模塊。
  2. #include <AFMotor.h>
  3. //int inputPin=13;  // 定義超聲波Trig
  4. //int outputPin=2; // 定義超聲波Echo
  5. AF_DCMotor motor1(1, MOTOR12_64KHZ);// 創建電機#1號,速度是64KHz pwm
  6. AF_DCMotor motor2(2, MOTOR12_64KHZ);// 創建電機#2號,速度是64KHz pwm
  7. AF_DCMotor motor3(3, MOTOR12_64KHZ);// 創建電機#2號,速度是64KHz pwm
  8. AF_DCMotor motor4(4, MOTOR12_64KHZ);// 創建電機#2號,速度是64KHz pwm
  9. void setup()
  10. {
  11.   Serial.begin(9600);
  12.   //pinMode(inputPin, INPUT);
  13. // pinMode(outputPin, OUTPUT);
  14.   motor1.setSpeed(150);// 設置電機速度,從200/255之間任意(我這倆電機速度不一樣,所以我就這樣設置)
  15.   motor2.setSpeed(150);// 設置電機速度,從200/255之間任意(大家可以按照自己的電機轉速來調節一樣的速度就可以了)
  16.   motor3.setSpeed(150);
  17.   motor4.setSpeed(150);
  18.   Serial.println("Motor test!");
  19. }
  20. void loop()
  21. {
  22.   //digitalWrite(outputPin, LOW); // 使發出發出超聲波信號接口低電平2μs
  23.   //delayMicroseconds(2);
  24. // digitalWrite(outputPin, HIGH); // 使發出發出超聲波信號接口高電平10μs,這里是至少10μs
  25. // delayMicroseconds(10);
  26. // digitalWrite(outputPin, LOW);    // 保持發出超聲波信號接口低電平
  27. // int distance = pulseIn(inputPin, HIGH);  // 讀出脈沖時間
  28. //distance= distance/58;   // 將脈沖時間轉化為距離(單位:厘米)
  29.   //Serial.println(distance);   //輸出距離值                 
  30.   delay(3000);   
  31.   //if (distance < 120 )   //大于50厘米就前進
  32.   //小車前進
  33.   {
  34.     //Serial.print("tick");
  35.     motor1.run(FORWARD);// 電機前進
  36.     motor2.run(FORWARD);// 電機前進
  37.     motor3.run(FORWARD);// 電機前進
  38.     motor4.run(FORWARD);// 電機前進
  39.   }
  40.   delay(3000);   
  41.   //if (distance > 50)   //小雨50厘米就后退
  42.   //小車后退
  43.   {
  44.     //Serial.print("tock");
  45.     motor1.run(BACKWARD);// 電機后退
  46.     motor2.run(BACKWARD);// 電機后退
  47.     motor3.run(BACKWARD);// 電機后退
  48.     motor4.run(BACKWARD);// 電機后退
  49.   }
  50.     //if (distance == 50)    //等于50厘米就停止
  51.     //小車停止
  52.     delay(3000);
  53.   {
  54.      //Serial.print("tack");
  55.      motor1.run(RELEASE);// 電機停止
  56.      motor2.run(RELEASE);// 電機停止
  57.      motor3.run(RELEASE);// 電機停止
  58.      motor4.run(RELEASE);// 電機停止
  59.   }
  60.   //小車左轉
  61.   delay(3000);
  62. {
  63.   motor1.run(FORWARD);// 電機前進
  64.   motor2.run(FORWARD);// 電機前進
  65.   motor3.run(BACKWARD);// 電機后退
  66.   motor4.run(BACKWARD);// 電機后退
  67. }  
  68. //小車右轉
  69.   delay(3000);
  70. {
  71.   motor3.run(FORWARD);// 電機前進
  72.   motor4.run(FORWARD);// 電機前進
  73.   motor1.run(BACKWARD);// 電機后退
  74.   motor2.run(BACKWARD);// 電機后退
  75. }  
  76. }
復制代碼

所有資料51hei提供下載:
lanyachuankou_41.zip (1.69 MB, 下載次數: 18)
1.zip (1.38 KB, 下載次數: 16)


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:404913 發表于 2019-4-2 21:03 | 只看該作者
請問可以出一個app的開發教程么?或者請指教一下
回復

使用道具 舉報

板凳
ID:560595 發表于 2019-6-28 16:12 | 只看該作者
arduino --board arduino:avr:yun --save-prefs
arduino -v --board arduino:avr:yun --pref build.path=mixlyBuild --verify "F:\Mixly0998/testArduino/testArduino.ino"
F:\Mixly0998\.\arduino-1.8.5\arduino-builder -dump-prefs -logger=machine -hardware F:\Mixly0998\.\arduino-1.8.5\hardware -tools F:\Mixly0998\.\arduino-1.8.5\tools-builder -tools F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -built-in-libraries F:\Mixly0998\.\arduino-1.8.5\libraries -libraries C:\Users\Administrator\Documents\Arduino\libraries -fqbn=arduino:avr:yun -ide-version=10806 -build-path F:\Mixly0998\mixlyBuild -warnings=null -prefs=build.path=mixlyBuild -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -verbose F:\Mixly0998\testArduino\testArduino.ino
F:\Mixly0998\.\arduino-1.8.5\arduino-builder -compile -logger=machine -hardware F:\Mixly0998\.\arduino-1.8.5\hardware -tools F:\Mixly0998\.\arduino-1.8.5\tools-builder -tools F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -built-in-libraries F:\Mixly0998\.\arduino-1.8.5\libraries -libraries C:\Users\Administrator\Documents\Arduino\libraries -fqbn=arduino:avr:yun -ide-version=10806 -build-path F:\Mixly0998\mixlyBuild -warnings=null -prefs=build.path=mixlyBuild -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr -verbose F:\Mixly0998\testArduino\testArduino.ino
Using board 'yun' from platform in folder: F:\Mixly0998\arduino-1.8.5\hardware\arduino\avr
Using core 'arduino' from platform in folder: F:\Mixly0998\arduino-1.8.5\hardware\arduino\avr
構建選項已變更,全部重新構建
Detecting libraries used...
"F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_YUN -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8041 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Yun"' "-IF:\Mixly0998\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IF:\Mixly0998\arduino-1.8.5\hardware\arduino\avr\variants\yun" "F:\Mixly0998\mixlyBuild\sketch\testArduino.ino.cpp" -o "nul"
"F:\Mixly0998\.\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10806 -DARDUINO_AVR_YUN -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8041 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Yun"' "-IF:\Mixly0998\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IF:\Mixly0998\arduino-1.8.5\hardware\arduino\avr\variants\yun" "F:\Mixly0998\mixlyBuild\sketch\testArduino.ino.cpp" -o "F:\Mixly0998\mixlyBuild\preproc\ctags_target_for_gcc_minus_e.cpp"
F:\Mixly0998\testArduino\testArduino.ino:2:21: fatal error: AFMotor.h: No such file or directory
#include <AFMotor.h>
                     ^
compilation terminated.
exit status 1
編譯失敗!
回復

使用道具 舉報

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

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表