小编Dan*_*oop的帖子

机器人不会动

我正在为学校项目建造机器人。我目前正在使用Arduino Uno,两个直流电动机和一个超声波传感器。这两个电机是通过Arduino Motor Shield v3控制的。我希望该机器人具有自主性,因此它必须能够使用超声波传感器自行移动。

这是我的源代码的最新版本:

#include <Servo.h>             // include Servo library
#include <AFMotor.h>       // include DC motor Library

#define trigPin 12               // define the pins of your sensor
#define echoPin 13

AF_DCMotor motor2(7);   // set up motors.
AF_DCMotor motor1(6);


void setup() {
    Serial.begin(9600);                 // begin serial communication  
    Serial.println("Motor test!");

    pinMode(trigPin, OUTPUT); // set the trig pin to output to send sound waves
    pinMode(echoPin, INPUT);   // set the echo pin to input to receive sound waves

    motor1.setSpeed(105);           // …
Run Code Online (Sandbox Code Playgroud)

robot arduino arduino-uno

5
推荐指数
1
解决办法
344
查看次数

标签 统计

arduino ×1

arduino-uno ×1

robot ×1