ZYAR20A 亚克力2驱 蓝牙 298寻迹避障机器人 —— 小车前进实验调试
生活随笔
收集整理的這篇文章主要介紹了
ZYAR20A 亚克力2驱 蓝牙 298寻迹避障机器人 —— 小车前进实验调试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在下載到開發板之前要選擇好板和端口,具體參見:
ZYAR20A 亞克力2驅 藍牙 298尋跡避障機器人 —— Arduino相關設置
// 智能小車前進實驗 //=============================================================== //#include <Servo.h> int Left_motor_go=8; //左電機前進(IN1) int Left_motor_back=9; //左電機后退(IN2)int Right_motor_go=10; // 右電機前進(IN3) int Right_motor_back=11; // 右電機后退(IN4)void setup() {//初始化電機驅動IO為輸出方式pinMode(Left_motor_go,OUTPUT); // PIN 8 8腳無PWM功能pinMode(Left_motor_back,OUTPUT); // PIN 9 (PWM)pinMode(Right_motor_go,OUTPUT);// PIN 10 (PWM) pinMode(Right_motor_back,OUTPUT);// PIN 11 (PWM) } void run(int time) // 前進 {digitalWrite(Right_motor_go,HIGH); // 右電機前進digitalWrite(Right_motor_back,LOW); analogWrite(Right_motor_go,100);//PWM比例0~255調速,左右輪差異略增減analogWrite(Right_motor_back,0); digitalWrite(Left_motor_go,LOW); // 左電機前進digitalWrite(Left_motor_back,HIGH);analogWrite(Left_motor_go,0);//PWM比例0~255調速,左右輪差異略增減analogWrite(Left_motor_back,100);}void loop() {delay(500);run(10); //前進 }總結
以上是生活随笔為你收集整理的ZYAR20A 亚克力2驱 蓝牙 298寻迹避障机器人 —— 小车前进实验调试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ZYAR20A 亚克力2驱 蓝牙 298
- 下一篇: 深度学习——02、深度学习入门——pyt