Stap 4: gedaan!!
/ Gebruik deze code om te testen uw motor met de linkit één bestuur: / / als u PWM moet, gebruik gewoon de PWM-uitgangen op de Arduino / / en in plaats van digitalWrite, moet u de opdracht analogWrite / /---[Motorsint motor_left] = {2, 3}; [int motor_right] = {7, 8}; / /---Setupvoid Setup {Serial.begin(9600); / / Setup motorsint ik; voor (ik = 0; ik < 2; i ++) {pinMode (motor_left [i] UITVOER); pinMode (motor_right [i], uitgang) ;}} ---Loopvoid loop {drive_forward();delay(1000);motor_stop(); Serial.println("1");drive_backward();delay(1000);motor_stop(); Serial.println("2");turn_left();delay(1000);motor_stop(); Serial.println("3");turn_right();delay(1000);motor_stop(); Serial.println("4"); motor_stop();delay(1000);motor_stop(); Serial.println("5");} ---Drivevoid motor_stop() {digitalWrite (motor_left [0], laag); digitalWrite (motor_left [1], laag); digitalWrite (motor_right [0], laag); digitalWrite (motor_right [1], LOW);delay(25);} VOID drive_forward() {digitalWrite (motor_left [0], hoge) digitalWrite (motor_left [1], laag); digitalWrite (motor_right [0], hoge); digitalWrite (motor_right [1], laag);} VOID drive_backward() {digitalWrite (motor_left [0], laag); digitalWrite (motor_left [1], hoge) digitalWrite (motor_right [0], laag); digitalWrite (motor_right [1], hoge);} VOID turn_left() {digitalWrite (motor_left [0], laag); digitalWrite (motor_left [1], hoge) digitalWrite (motor_right [0], hoge); digitalWrite (motor_right [1], laag);} VOID turn_right() {digitalWrite (motor_left [0], hoge) digitalWrite (motor_left [1], laag); digitalWrite (motor_right [0], laag); digitalWrite (motor_right [1], hoge);}
Hoop dat u liked it.
Dank u!!