我正在使用arduino uno r3上的V2.3 motorheild。 我從過去的一週讀到的關於ardunio excpet的文章幾乎沒有。 我一直在試圖簡單地用下面的代碼轉動電機,它不會工作。我把arduino插入了我的電腦,12v插上了藍色電源盒。 我使用這個馬達https://www.servocity.com/html/900_rpm_micro_gearmotorblocks.html#.VyELIFaDFBc 我不能讓黨的事情旋轉,如果我線它電機工作正常直行至5V/GRND而不是當它在M1連接 接線:https://i.groupme.com/747x1328.png.54a01e30433241d4a99905bd0e8ede2b讓meknow如果這個環節不工作 這裏有一個Imgur鏈接,接線http://imgur.com/J92ewnu 的#includeArduino Uno直流電機不能用簡單的測試工作。無法讓Arduino旋轉電機
AF_DCMotor motor(1);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motor.setSpeed(200);
motor.run(RELEASE);
}
void loop() {
uint8_t i;
Serial.print("tick");
motor.run(FORWARD);
for (i=0; i<255; i++) {
motor.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor.setSpeed(i);
delay(10);
}
Serial.print("tock");
motor.run(BACKWARD);
for (i=0; i<255; i++) {
motor.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
motor.setSpeed(i);
delay(10);
}
Serial.print("tech");
motor.run(RELEASE);
delay(1000);
}
你有沒有嘗試下面的adafruit教程,他們通常解釋得非常好:) –