Paso 4: hacer!!!!
/ Utilizar este código para probar el motor con la un junta linkit: / / Si necesita PWM, sólo tiene que utilizar las salidas PWM de Arduino / / y en vez de digitalWrite, debe utilizar el comando analogWrite / /---Motorsint motor_left [] = {2, 3}; int motor_right [] = {7, 8}; / /---Setupvoid setup() {Serial.begin(9600); / / Setup motorsint; para (i = 0; me < 2; i ++) {pinMode (motor_left [i] SALIDA); pinMode (motor_right [i], salida) ;}} ---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], LOW); digitalWrite (motor_left [1], LOW); digitalWrite (motor_right [0], LOW); digitalWrite (motor_right [1], LOW);delay(25);} void drive_forward() {digitalWrite (motor_left [0], HIGH); digitalWrite (motor_left [1], LOW); digitalWrite (motor_right [0], HIGH); digitalWrite (motor_right [1], LOW);} void drive_backward() {digitalWrite (motor_left [0], LOW); digitalWrite (motor_left [1], HIGH); digitalWrite (motor_right [0], LOW); digitalWrite (motor_right [1], HIGH);} void turn_left() {digitalWrite (motor_left [0], LOW); digitalWrite (motor_left [1], HIGH); digitalWrite (motor_right [0], HIGH); digitalWrite (motor_right [1], LOW);} void turn_right() {digitalWrite (motor_left [0], HIGH); digitalWrite (motor_left [1], LOW); digitalWrite (motor_right [0], LOW); digitalWrite (motor_right [1], HIGH);}
Espero que os haya gustado.
¡¡Gracias!!