久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

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

自己寫的一個(gè)人藍(lán)牙Arduino小車程序源碼

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
自己寫的一個(gè)人藍(lán)牙Arduino小車,附件有藍(lán)牙串口助手


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

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


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

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

使用道具 舉報(bào)

沙發(fā)
ID:404913 發(fā)表于 2019-4-2 21:03 | 只看該作者
請(qǐng)問可以出一個(gè)app的開發(fā)教程么?或者請(qǐng)指教一下
回復(fù)

使用道具 舉報(bào)

板凳
ID:560595 發(fā)表于 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
構(gòu)建選項(xiàng)已變更,全部重新構(gòu)建
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
編譯失敗!
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 偷拍自拍网址 | 97偷拍视频 | 成人在线视频免费观看 | 国产精品亚洲综合 | 网站一区二区三区 | 99久久夜色精品国产亚洲96 | 国产日韩欧美一区二区 | 欧美视频精品 | 九九热免费在线观看 | 黑人精品欧美一区二区蜜桃 | 日韩av在线一区 | 97日日碰人人模人人澡分享吧 | 天天干狠狠操 | 亚洲国产一区视频 | 日本黄色一级片视频 | 国产精品毛片一区二区三区 | 中文字幕乱码一区二区三区 | www国产成人免费观看视频,深夜成人网 | 日韩综合一区 | 人人爽日日躁夜夜躁尤物 | 91亚洲精品久久久电影 | 91在线精品秘密一区二区 | 国产精品久久久久无码av | 国产在线1 | 中文字幕一区二区三区精彩视频 | 99精品欧美一区二区蜜桃免费 | 这里精品| gogo肉体亚洲高清在线视 | 精品国产鲁一鲁一区二区张丽 | 日韩一区二区在线视频 | 2020国产在线 | 欧美在线国产精品 | 精品视频一区二区在线观看 | 免费黄色的视频 | 91在线精品秘密一区二区 | 综合色播| 国内精品久久久久久久 | 日批免费在线观看 | 一区二区三区在线免费观看视频 | 日本黄视频在线观看 | 亚洲精品国产精品国自产在线 |