Arduino (IoT) Video Serie: Kit de Carro Parte 3

Arduino Honduras Santiapps Marcio Valenzuela

Arduino IoT: Video tutorial Kit de Carro Parte 3

Este es el codigo final:

#include  <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor3(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor4(4, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  
  motor1.setSpeed(200);     // set the speed to 200/255
  motor2.setSpeed(200);     // set the speed to 200/255
  motor3.setSpeed(200);     // set the speed to 200/255
  motor4.setSpeed(200);     // set the speed to 200/255
}

void loop() {
  
  motor1.run(FORWARD);      // turn it on going forward
  delay(1000);
  motor1.run(BACKWARD);     // the other way
  delay(1000);
  motor1.run(RELEASE);      // stopped
  delay(5000);

  motor2.run(FORWARD);      // turn it on going forward
  delay(1000);
  motor2.run(BACKWARD);     // the other way
  delay(1000);
  motor2.run(RELEASE);      // stopped
  delay(1000);

  motor3.run(FORWARD);      // turn it on going forward
  delay(1000);
  motor3.run(BACKWARD);     // the other way
  delay(1000);
  motor3.run(RELEASE);      // stopped
  delay(5000);

  motor4.run(FORWARD);      // turn it on going forward
  delay(1000);
  motor4.run(BACKWARD);     // the other way
  delay(1000);
  motor4.run(RELEASE);      // stopped
  delay(1000);
}

void forward(){}
void backward(){}
void brakes(){}

Leave a Reply