Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

robotics diy project sample

Last updated on 6 months ago
C
caaSuper Admin
Posted 6 months ago
Project: Arduino Obstacle-Avoiding Robot

Components Needed:

Arduino board (e.g., Arduino Uno)
Ultrasonic sensor (HC-SR04)
Motor driver module (L298N)
Two DC motors
Chassis and wheels
Battery pack (6xAA batteries) or a rechargeable battery pack
Jumper wires
Breadboard (optional)
Instructions:

Assemble the Robot:

Assemble the chassis, attach the DC motors to the wheels, and mount the wheels to the chassis.
Connect the motor driver module to the motors and the Arduino.
Connect the Ultrasonic Sensor:

Connect the VCC and GND pins of the ultrasonic sensor to the Arduino's 5V and GND pins, respectively.
Connect the Echo and Trig pins of the sensor to any two digital pins on the Arduino (e.g., D2 and D3).
Programming:

Write the Arduino code for the obstacle-avoiding behavior. This code will use the ultrasonic sensor to detect obstacles and make the robot move forward, backward, left, or right to avoid collisions.
Edited by caa on 03-11-2023 15:38, 6 months ago
C
caaSuper Admin
Posted 6 months ago
#include <NewPing.h>

#define TRIGGER_PIN 2
#define ECHO_PIN 3
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
int motor1Pin1 = 9;
int motor1Pin2 = 10;
int motor2Pin1 = 5;
int motor2Pin2 = 6;
void setup() {
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
}
void loop() {
int distance = sonar.ping_cm();
if (distance < 20) {
// Obstacle detected, turn left
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
} else {
// No obstacle, move forward
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
}
}
Edited by caa on 03-11-2023 15:40, 6 months ago
C
caaSuper Admin
Posted 6 months ago
Upload the Code:

Connect the Arduino to your computer and upload the code using the Arduino IDE.
Power the Robot:

Power the robot with the battery pack or a suitable power source.
Test Your Robot:

Place obstacles in front of the robot and observe how it navigates to avoid collisions.
This simple project demonstrates the basics of robotics, sensor integration, and autonomous behavior. You can expand on this project by adding more sensors, improving obstacle avoidance algorithms, and even implementing remote control via Bluetooth or Wi-Fi.
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?