Hello

Welcome lekule blog

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation.
together in the world. #lekule86
Join us on

The Antisocial RobotCar (EAL)

The Antisocial RobotCar moves away from you if you get too close and stops if there is nothing close.

Step 1: Overview

Overview
We wanted to build an antisocial robot car that moves away from obstacles/people.
The way it works is by having 2 Ultra sonic sensors in each end of the car. The car can only move forward and backwards.
If anything get to close to the car <50cm away="" drive="" is="" it="" obstacle="" of="" out="" p="" range.="" the="" until="" will="">It uses 2 DC motors controlled by a L298 DC dual motor controller to move both forwards and backwards.
To power the DC motors we use 3 LIthium batteries cabable to deliver approx 11V to the motors.
Everything is controlled by the Arduino Mega 2560 which all of the components is connected to.

Step 2: Part List

2 X DC Motor, 4 to 24V
1 X Battery Case 3 battery slots
3 X 3,7V Battery
1 X L298N DC Motordriver
2 X Ultrasonic modul hc-SR04
1 X Arduino mega 2560
1 X 9V Battery Cable for Arduino
1 X 9V Battery
3 X Wheels.

Step 3: Building the Car

Building the Car
Start by getting a large piece of plastic board and make holes for you to strap on the components. After having drawn up the holes and made them, attach them to the board.

Use the wiring diagram to connet the components corretly together.
Remeber to make shared ground and wire up the motor driver to the Arduino correctly. If not connected correct, it might not drive or it might drive in the wrong direction.

Remember to secure the connection between the Ultrasonic moduls to the Arduino correctly, or you might have some instable readings.

Step 4: Wiring Diagram

Wiring Diagram
This diragram shows the electrical curcuit in the system.

Step 5: The Code

[code]
//Keyboard Controls: // // 1 -Motor 1 Left // 2 -Motor 1 Stop // 3 -Motor 1 Right // // 4 -Motor 2 Left // 5 -Motor 2 Stop // 6 -Motor 2 Right
// Declare L298N Dual H-Bridge Motor Controller directly since there is not a library to load.
// Motor 1 int dir1PinA = 9; int dir2PinA = 8; int speedPinA = 10; // Needs to be a PWM pin to be able to control motor speed
// Motor 2 int dir1PinB = 5; int dir2PinB = 4; int speedPinB = 7; // Needs to be a PWM pin to be able to control motor speed
int inByteRight; int inByteLeft;
// Ultra-Sound-Sensor 1
#define echoPin1 2 #define trigPin1 3
long duration1, distanceFront;
// Ultra-Sound-Sensor 2
#define echoPin2 11 #define trigPin2 12
long duration2, distanceBack;
void setup() { // Setup runs once per reset
// initialize serial communication @ 9600 baud: Serial.begin(9600);
//Define L298N Dual H-Bridge Motor Controller Pins
pinMode(dir1PinA,OUTPUT); pinMode(dir2PinA,OUTPUT); pinMode(speedPinA,OUTPUT); pinMode(dir1PinB,OUTPUT); pinMode(dir2PinB,OUTPUT); pinMode(speedPinB,OUTPUT);
//Define Ultra-sound-sensor Pins
pinMode(trigPin1, OUTPUT); pinMode(trigPin2, OUTPUT); pinMode(echoPin1, INPUT); pinMode(echoPin2, INPUT);
}
void loop() {
// Ultra-sound-sensor 1 Loop
digitalWrite(trigPin1, LOW); delayMicroseconds(2); digitalWrite(trigPin1, HIGH); delayMicroseconds(10); digitalWrite(trigPin1, LOW); duration1 = pulseIn(echoPin1, HIGH); distanceFront = duration1/58.2;
Serial.print("DistanceFront in cm = "); Serial.println(distanceFront);
delay(10);
// Ultra-sound-sensor 2 Loop
digitalWrite(trigPin2, LOW); delayMicroseconds(2); digitalWrite(trigPin2, HIGH); delayMicroseconds(10); digitalWrite(trigPin2, LOW); duration2 = pulseIn(echoPin2, HIGH); distanceBack = duration2/58.2;
Serial.print("DistanceBack in cm = "); Serial.println(distanceBack);
delay(10);
//Moving Backwards....
if (distanceBack > 25 && distanceFront < 50) { inByteLeft=1; inByteRight=3; } else { Serial.println("Else"); }
//Moving Forwards....
if (distanceBack < 50 && distanceFront > 25) { inByteLeft=3; inByteRight=1; } else { Serial.println("Else"); }
//Stop....
if (distanceBack > 25 && distanceFront > 25) { inByteLeft=2; inByteRight=2; } else { Serial.println("Else"); }
//too close....
if (distanceBack < 25 && distanceFront < 25) { inByteLeft=2; inByteRight=2; } else { Serial.println("Else"); }
switch (inByteLeft) { //______________Motor 1______________
case 1: // Motor 1 Forward analogWrite(speedPinA, 255);//Sets speed variable via PWM digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); Serial.println("Motor 1 Forward"); // Prints out “Motor 1 Forward” on the serial monitor Serial.println(" "); // Creates a blank line printed on the serial monitor break;
case 2: // Motor 1 Stop (Freespin) analogWrite(speedPinA, 0); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); Serial.println("Motor 1 Stop"); Serial.println(" "); break;
case 3: // Motor 1 Reverse analogWrite(speedPinA, 255); digitalWrite(dir1PinA, HIGH); digitalWrite(dir2PinA, LOW); Serial.println("Motor 1 Reverse"); Serial.println(" "); break;
default: // turn all the connections off if an unmapped key is pressed: Serial.println(" "); }
switch (inByteRight) { //______________Motor 2______________
case 1: // Motor 2 Forward analogWrite(speedPinB, 255); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); Serial.println("Motor 2 Forward"); Serial.println(" "); break;
case 2: // Motor 2 Stop (Freespin) analogWrite(speedPinB, 0); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); Serial.println("Motor 2 Stop"); Serial.println(" "); break;
case 3: // Motor 2 Reverse analogWrite(speedPinB, 255); digitalWrite(dir1PinB, HIGH); digitalWrite(dir2PinB, LOW); Serial.println("Motor 2 Reverse"); Serial.println(" "); break;
default: // turn all the connections off if an unmapped key is pressed: Serial.println(" "); } }
[/code]

Step 6: Extra

Extra
Extra pictures of the car

Step 7: I/O List for the Arduino

Digital Outputs
Motor A
dir1PinA = 9;
dir2PinA = 8;
speedPinA = 10'
Motor B
dir1PinB = 5;
dir2PinB = 4;
speedPinB = 7;
Ultrasonic Front
trigPin1 = 3
Ultrasonic Back
trigPin2 = 12
Digital Inputs
Ultrasonic Front
echoPin1 = 2
Ultrasonic Back
echoPin2 = 11
Power
5v to ultrasonic
2x GND shared

Share this:

ABOUTME

Hi all. This is deepak from Bthemez. We're providing content for Bold site and we’ve been in internet, social media and affiliate for too long time and its my profession. We are web designer & developer living India! What can I say, we are the best..

Post a Comment
My photo

Hi, I`m Sostenes, Electrical Technician and PLC`S Programmer.
Everyday I`m exploring the world of Electrical to find better solution for Automation. I believe everyday can become a Electrician with the right learning materials.
My goal with BLOG is to help you learn Electrical.

Labels

LEKULE TV EDITORIALS ARTICLES DC ROBOTICS DIGITAL SEMICONDUCTORS GENERATOR AC EXPERIMENTS MANUFACTURING-ENGINEERING REFERENCE FUNDAMENTAL OF ELECTRICITY ELECTRONICS ELECTRICAL ENGINEER MEASUREMENT TRANSDUCER & SENSOR VIDEO ARDUINO RENEWABLE ENERGY AUTOMOBILE TEARDOWN SYNCHRONOUS GENERATOR DIGITAL ELECTRONICS ELECTRICAL DISTRIBUTION CABLES AUTOMOTIVE MICROCONTROLLER SOLAR PROTECTION DIODE AND CIRCUITS BASIC ELECTRICAL ELECTRONICS MOTOR SWITCHES CIRCUIT BREAKERS CIRCUITS THEORY PANEL BUILDING ELECTRONICS DEVICES MIRACLES SWITCHGEAR ANALOG MOBILE DEVICES WEARABLES CAMERA TECHNOLOGY COMMUNICATION GENERATION BATTERIES FREE CIRCUITS INDUSTRIAL AUTOMATION SPECIAL MACHINES ELECTRICAL SAFETY ENERGY EFFIDIENCY-BUILDING DRONE CONTROL SYSTEM NUCLEAR ENERGY SMATRPHONE FILTER`S POWER BIOGAS BELT CONVEYOR MATERIAL HANDLING RELAY ELECTRICAL INSTRUMENTS ENERGY SOURCE PLC`S TRANSFORMER AC CIRCUITS CIRCUIT SCHEMATIC SYMBOLS DDISCRETE SEMICONDUCTOR CIRCUITS WIND POWER C.B DEVICES DC CIRCUITS DIODES AND RECTIFIERS FUSE SPECIAL TRANSFORMER THERMAL POWER PLANT CELL CHEMISTRY EARTHING SYSTEM ELECTRIC LAMP FUNDAMENTAL OF ELECTRICITY 2 BIPOLAR JUNCTION TRANSISTOR 555 TIMER CIRCUITS AUTOCAD BLUETOOTH C PROGRAMMING HOME AUTOMATION HYDRO POWER LOGIC GATES OPERATIONAL AMPLIFIER`S SOLID-STATE DEVICE THEORRY COMPUTER DEFECE & MILITARY FLUORESCENT LAMP INDUSTRIAL ROBOTICS ANDROID ELECTRICAL DRIVES GROUNDING SYSTEM CALCULUS REFERENCE DC METERING CIRCUITS DC NETWORK ANALYSIS ELECTRICAL SAFETY TIPS ELECTRICIAN SCHOOL ELECTRON TUBES FUNDAMENTAL OF ELECTRICITY 1 INDUCTION MACHINES INSULATIONS USB ALGEBRA REFERENCE HMI[Human Interface Machines] INDUCTION MOTOR KARNAUGH MAPPING USEUL EQUIATIONS AND CONVERSION FACTOR ANALOG INTEGRATED CIRCUITS BASIC CONCEPTS AND TEST EQUIPMENTS DIGITAL COMMUNICATION DIGITAL-ANALOG CONVERSION ELECTRICAL SOFTWARE GAS TURBINE ILLUMINATION OHM`S LAW POWER ELECTRONICS THYRISTOR BOOLEAN ALGEBRA DIGITAL INTEGRATED CIRCUITS FUNDAMENTAL OF ELECTRICITY 3 PHYSICS OF CONDUCTORS AND INSULATORS SPECIAL MOTOR STEAM POWER PLANTS TESTING TRANSMISION LINE C-BISCUIT CAPACITORS COMBINATION LOGIC FUNCTION COMPLEX NUMBERS CONTROL MOTION ELECTRICAL LAWS INVERTER LADDER DIAGRAM MULTIVIBRATORS RC AND L/R TIME CONSTANTS SCADA SERIES AND PARALLEL CIRCUITS USING THE SPICE CIRCUIT SIMULATION PROGRAM AMPLIFIERS AND ACTIVE DEVICES APPS & SOFTWARE BASIC CONCEPTS OF ELECTRICITY CONDUCTOR AND INSULATORS TABLES CONDUITS FITTING AND SUPPORTS ELECTRICAL INSTRUMENTATION SIGNALS ELECTRICAL TOOLS INDUCTORS LiDAR MAGNETISM AND ELECTROMAGNETISM PLYPHASE AC CIRCUITS RECLOSER SAFE LIVING WITH GAS AND LPG SAFETY CLOTHING STEPPER MOTOR SYNCHRONOUS MOTOR AC METRING CIRCUITS BECOME AN ELECTRICIAN BINARY ARITHMETIC BUSHING DIGITAL STORAGE MEMROY ELECTRICIAN JOBS HEAT ENGINES HOME THEATER INPECTIONS LIGHT SABER MOSFET NUMERATION SYSTEM POWER FACTORS REACTANCE AND IMPEDANCE INDUCTIVE RECTIFIER AND CONVERTERS RESONANCE SCIENTIFIC NOTATION AND METRIC PREFIXES SULFURIC ACID TROUBLESHOOTING TROUBLESHOOTING-THEORY & PRACTICE 12C BUS APPLE BATTERIES AND POWER SYSTEMS DC MOTOR DRIVES ELECTROMECHANICAL RELAYS ENERGY EFFICIENCY-LIGHT INDUSTRIAL SAFETY EQUIPMENTS MEGGER MXED-FREQUENCY AC SIGNALS PRINCIPLE OF DIGITAL COMPUTING QUESTIONS REACTANCE AND IMPEDANCE-CAPATIVE SEQUENTIAL CIRCUITS SERRIES-PARALLEL COMBINATION CIRCUITS SHIFT REGISTERS WIRELESS BUILDING SERVICES COMPRESSOR CRANES DIVIDER CIRCUIT AND KIRCHHOFF`S LAW ELECTRICAL DISTRIBUTION EQUIPMENTS 1 ELECTRICAL DISTRIBUTION EQUIPMENTS B ELECTRICAL TOOL KIT ELECTRICIAN JOB DESCRIPTION INDUSTRIAL DRIVES LAPTOP SCIENCE THERMOCOUPLE TRIGONOMENTRY REFERENCE UART oscilloscope BIOMASS CONTACTOR ELECTRIC ILLUMINATION ELECTRICAL SAFETY TRAINING ELECTROMECHANICAL FEATURED FILTER DESIGN HARDWARE JUNCTION FIELD-EFFECT TRANSISTORS NASA NUCLEAR POWER VALVE COLOR CODES ELECTRIC TRACTION FLEXIBLE ELECTRONICS FLUKE GEARMOTORS INTRODUCTION LASSER PID PUMP SEAL ELECTRICIAN CAREER ELECTRICITY SUPPLY AND DISTRIBUTION MUSIC NEUTRAL PERIODIC TABLES OF THE ELEMENTS POLYPHASE AC CIRCUITS PROJECTS REATORS SATELLITE STAR DELTA VIBRATION WATERPROOF