Webdroid Edutech
Published

Building a Four-in-One Arduino Robot

This project demonstrates how to build a four-in-one multifunctional robot using an Arduino Uno. The robot is capable of operating in four d

BeginnerProtip30
Building a Four-in-One Arduino Robot

Things used in this project

Hardware components

4WD Car Chassis Kit
×1
L298N Motor Driver Module
×1
Jumper Wires
×1
7-12 V DC Battery (in our case lipo 2s battery)
×1
Arduino Uno
×1
Breadboard
×1
Ultrasonic Sensor
×1
Servo Motor (SG90)
×1

Story

Read more

Code

Code

Arduino
#include <NewPing.h>
#define TRIG_PIN 7
#define ECHO_PIN 8
#define MAX_DISTANCE 200
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);
 
#define IN1 5
#define IN2 6
#define IN3 9
#define IN4 10
 
void setup() {
    pinMode(IN1, OUTPUT);
    pinMode(IN2, OUTPUT);
    pinMode(IN3, OUTPUT);
    pinMode(IN4, OUTPUT);
}
 
void loop() {
    int distance = sonar.ping_cm();
    if (distance > 0 && distance < 20) {
        avoidObstacle();
    } else {
        followLine();
    }
}

Credits

Webdroid Edutech
12 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.