Hi to all

hi i bay my frst arduino board and I want to make obstacle avoiding robot parts what i have:
Micro serve sc 90
Two dc motors
Ping senzor hc-sr04
Arduino unol
l293b motor driver
and breadboard
this diagram but for the component that currently have
My question is if someone can make me a circuit diagram of how to connect all this and and code of course :stuck_out_tongue:

I am new at this :slight_smile:

circuit.jpg

20100327144444_L293B_7687.jpg

My question is if someone can make me a circuit diagram of how to connect all this and and code of course

That is probably not going to happen. What would you get out of a project that somebody gave you all the code for and came up with the design. We will give you tips and pointers but never give you all the code + make a diagram.

I will look over what you have and see If I can give you some ideas.

EDIT:

From a quick glance your diagram looks fine. Why would you need a new one? Try it out and see what happens.
As for the code do it one step at a time. Try printing the values from your sensors to serial monitor. Google will be your best friend :slight_smile:

This might help as well. How to make wall/obstacle avoiding robot with arduino uno atmega 328 - Robotics - Arduino Forum

is it posible to conect twoo dc motors and one servo motor directly to arduino without using arduino motor shield or motor or l293b motor driver

Just connect everything according to the design you already have! Connecting two dc motors to your Arduino directly is never a good idea!

Dexter87:
is it posible to conect twoo dc motors and one servo motor directly to arduino without using arduino motor shield or motor or l293b motor driver

You need a chip like the 293 or similar to take care of motor direction control. You don’t need a shield though, no: as you have shown in your Fritzing pic, a breadboard makes it quite simple. You shouldn’t power the motors from the Arduino, as Drew said, although (as in your design) it’s ok to control them from the Arduino.

You could look for code examples of how to do three things separately first:

  • How to drive a servo motor: check the tutorials page
  • How to drive dc motors with the 293: check the playground
  • How to read the sensor: check the playground

Then give some thought as to how you’ll get all three of those things happening together: but my advice is strongly to do them one at a time at first.

Building a robot using jumpers to a whiteboard is a very low-reliability solution. Given what you've already invested in the robot base, you're probably better off getting an adafruit motor shield - already has the L293D and connections for servos.

Then, for connecting other things like sensors, use a prototyping shield, eg

or else mount the L293 on the proto board in the first place, via 16-pin socket. Toss the whiteboard in a box in the closet.

Do you have a link to that base, so we can see what the motors are?

Building a robot using jumpers to a whiteboard is a very low-reliability solution. Given what you've already invested in the robot base, you're probably better off getting an adafruit motor shield - already has the L293D and connections for servos.

Good point: I meant he didn't have to have a shield, but you're absolutely right a shield with some prototyping space and or one of those tiny bread boards stuck on top sheer convenience, is a better way.

i hawe code for my robot bat i using 4 pin ping sezor howe to modifie this code for this senzor my senzor is HC-SR04

int sensorpin = 0; // analog pin used to connect the sharp sensor
int val = 0; // variable to store the values from sensor(initially zero)

void setup()
{
Serial.begin(9600); // starts the serial monitor
}

void loop()
{
val = analogRead(sensorpin); // reads the value of the sharp sensor
Serial.println(val); // prints the value of the sensor to the serial monitor
}

int motor_pin1 = 4; //define the pins to which motor wires are connected

int motor_pin2 = 5;

void setup ()
{
pinMode(motor_pin1,OUTPUT); // set the motor pins as output
pinMode(motor_pin2,OUTPUT);
}

void loop()
{
digitalWrite(motor_pin1,HIGH);
digitalWrite(motor_pin2,LOW);
}
int motor_pin1 = 4; //define the pins to which motor wires are connected
int motor_pin2 = 5;

void setup ()
{
pinMode(motor_pin1,OUTPUT); // set the motor pins as output
pinMode(motor_pin2,OUTPUT);
}

void loop()
{
digitalWrite(motor_pin1,LOW);
digitalWrite(motor_pin2,HIGH);
}
int motor_pin3 = 6; //define the pins to which motor wires are connected
int motor_pin4 = 7;

void setup ()
{
pinMode(motor_pin3,OUTPUT); // set the motor pins as output
pinMode(motor_pin4,OUTPUT);
}

void loop()
{
digitalWrite(motor_pin3,HIGH);
digitalWrite(motor_pin4,LOW);
}
#include <Servo.h> //includes the servo library

int motor_pin1 = 4;
int motor_pin2 = 5;
int motor_pin3 = 6;
int motor_pin4 = 7;
int servopin = 8;
int sensorpin = 0;
int dist = 0;
int leftdist = 0;
int rightdist = 0;
int object = 500; //distance at which the robot should look for another route

Servo myservo;

void setup ()
{
pinMode(motor_pin1,OUTPUT);
pinMode(motor_pin2,OUTPUT);
pinMode(motor_pin3,OUTPUT);
pinMode(motor_pin4,OUTPUT);
myservo.attach(servopin);
myservo.write(90);
delay(700);
}
void loop()
{
dist = analogRead(sensorpin); //reads the sensor

if(dist < object) { //if distance is less than 550
forward(); //then move forward
}
if(dist >= object) { //if distance is greater than or equal to 550
findroute();
}
}

void forward() { // use combination which works for you
digitalWrite(motor_pin1,HIGH);
digitalWrite(motor_pin2,LOW);
digitalWrite(motor_pin3,HIGH);
digitalWrite(motor_pin4,LOW);
return;
}

void findroute() {
halt(); // stop
backward(); //go backwards
lookleft(); //go to subroutine lookleft
lookright(); //go to subroutine lookright

if ( leftdist < rightdist )
{
turnleft();
}
else
{
turnright ();
}
}

void backward() {
digitalWrite(motor_pin1,LOW);
digitalWrite(motor_pin2,HIGH);
digitalWrite(motor_pin3,LOW);
digitalWrite(motor_pin4,HIGH);
delay(500);
halt();
return;
}

void halt () {
digitalWrite(motor_pin1,LOW);
digitalWrite(motor_pin2,LOW);
digitalWrite(motor_pin3,LOW);
digitalWrite(motor_pin4,LOW);
delay(500); //wait after stopping
return;
}

void lookleft() {
myservo.write(150);
delay(700); //wait for the servo to get there
leftdist = analogRead(sensorpin);
myservo.write(90);
delay(700); //wait for the servo to get there
return;
}

void lookright () {
myservo.write(30);
delay(700); //wait for the servo to get there
rightdist = analogRead(sensorpin);
myservo.write(90);
delay(700); //wait for the servo to get there
return;
}

void turnleft () {
digitalWrite(motor_pin1,HIGH); //use the combination which works for you
digitalWrite(motor_pin2,LOW); //right motor rotates forward and left motor backward
digitalWrite(motor_pin3,LOW);
digitalWrite(motor_pin4,HIGH);
delay(1000); // wait for the robot to make the turn
halt();
return;
}

void turnright () {
digitalWrite(motor_pin1,LOW); //use the combination which works for you
digitalWrite(motor_pin2,HIGH); //left motor rotates forward and right motor backward
digitalWrite(motor_pin3,HIGH);
digitalWrite(motor_pin4,LOW);
delay(1000); // wait for the robot to make the turn
halt();
return;
}

what is the point of this if you don't want help?

People here don't generally write other people's code for them. Especially when it's "easy" to find someone else who has already written it.

what is the point of this if you don’t want to help?

The point is to interact and bounce ideas off of other Arduino fans. The point is not for us to be your servants.

The problem is that you started with a project that is way past your capability. Try making some led’s blink and the other basics. After a few months of learning and experimenting with Arduino then try to make the code for your servo, then work on your sensor, and finally your motors. When you run into issues try to work them out with the help of google and if you still don’t understand come ask us to point you in the right direction. Your not going to get far in life by doing this…

My question is if someone can make me a circuit diagram of how to connect all this and and code of course

Hi, I agree with Drew, start programming your arduino with simple projects.
If you want to get into making your robot, start with one part at a time.
For example, do a couple of the simple arduino tutorials on reading and outputting, then move to getting your motors to run in whatever direction you need.
Then controlling the servo.
Then ping the PingSensor.
Then simple interaction between ping and motor drive.
It will take time to do, but we can help you as you progress, with bits of code and hardware suggestions.
Tom... :slight_smile: