Free Shipping over β‚Ή1199

ESP32-C3 SMARS Robot: 3D-Printed

Introduction

The ESP32-C3 SMARS Robot is a compact, 3D-printed robot platform.
It is powered by the ESP32-C3 Super Mini with Expansion Board.
An ultrasonic sonar sensor helps the robot detect and avoid obstacles.
Dual N20 3V metal gear motors are driven by a Mini Dual DC Motor Driver for smooth motion.
A push button with a 10K resistor provides manual control and reset functionality.

Required Components

  • ESP32-C3 Super mini with Expension Board
  • Sonar Sensor
  • Push Button with 10K Ohm Resistor
  • Mini Dual DC Motor Driver
  • N20 DC 3V Metal Gear Motor
  • Zero PCB

3D Parts

πŸ‘‰Click to Download

Circuit Diagram

  • HC-SR04
    • VCC β†’ ESP32-C3 5V
    • GND β†’ ESP32-C3 GND
    • TRIG β†’ ESP32-C3 10
    • ECHO β†’ ESP32-C3 5
  • Motor Driver
    • IN1 β†’ ESP32-C3 6 (motor A control pin 1)
    • IN2 β†’ ESP32-C3 7 (motor A control pin 2)
    • IN3 β†’ ESP32-C3 8 (motor B control pin 1)
    • IN4 β†’ ESP32-C3 9 (motor B control pin 2)
  • Motors
    • Motor A outputs β†’ Driver Motor A output pins
    • Motor B outputs β†’ Driver Motor B output pins
  • Push Button
    • One Side of Push Button β†’ ESP32-C3 5V with 10k Ohm Resistor (For pullup)
    • One Side of Push Buttonβ†’ ESP32-C3 GND
    • One Side of Push Button β†’ ESP32-C3 4

Code

#define TRIG_PIN 10
#define ECHO_PIN 5

#define IN1 6
#define IN2 7
#define IN3 8
#define IN4 9

long duration;
int distance;

void setup() {
  Serial.begin(115200);

  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);

  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  // Measure distance
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  duration = pulseIn(ECHO_PIN, HIGH);
  distance = duration * 0.034 / 2;

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  if (distance < 15) {
    // Obstacle: go backward
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
    delay(500);

    // Turn right
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
    delay(500);
  } else {
    // Move forward
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);
  }

  delay(100);
}

    Leave a Reply

    Your email address will not be published. Required fields are marked *


    Need Help?