proyecto traccion CJ — Esp32 Devkit C V4 simulation

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by std2401043.

Components

Sketch code

#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Instancia del controlador de motores I2C en la dirección 0x60
Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x60); 

// Asignación de los 4 puertos de motor
Adafruit_DCMotor *m1 = AFMS.getMotor(1);
Adafruit_DCMotor *m2 = AFMS.getMotor(2);
Adafruit_DCMotor *m3 = AFMS.getMotor(3);
Adafruit_DCMotor *m4 = AFMS.getMotor(4);

void setup() {
  Serial.begin(115200);
  Serial.println("Iniciando bus I2C en ESP32...");

  // Configurar pines I2C del ESP32 (GPIO 21 = SDA, GPIO 22 = SCL)
  Wire.begin(21, 22);

  // Inicializar placa de motores
  if (!AFMS.begin()) {
    Serial.println("Error: No se encontro el controlador I2C. Revisa VCC y GND.");
    while (1);
  }

  Serial.println("Controlador detectado. Arrancando motores...");

  // Configurar velocidad máxima (0 a 255)
  m1->setSpeed(255);
  m2->setSpeed(255);
  m3->setSpeed(255);
  m4->setSpeed(255);

  // Activar giro en sentido directo
  m1->run(FORWARD);
  m2->run(FORWARD);
  m3->run(FORWARD);
  m4->run(FORWARD);
}

void loop() {
  // Mantener los motores encendidos
  delay(1000);
}

More projects by std2401043