Saturday, December 22, 2018

HOW TO MAKE SELF ROBOT

 


The Self  Robot Obstacle Detect  Path Can be found. How to make a self robot go to stepwise.

Components Used:-

  1. Plastic Box                    - Buy
  2. DC motor-2                  -Buy
  3. Switch                           -Buy
  4. Ultrasonic Senser       -Buy
  5. Servo Motor                 -Buy
  6. Castor Wheel               -Buy
  7. Arduino                        -Buy
  8. Motor Drive                 - Buy
  9. Battery-9v                    -Buy

              STEP(1)

  STEP(2)




  STEP(3)





  STEP(4)








  STEP(5)

Ultrasonic Sensor is Four terminal  VCC, GND, Trig. , Echo. 
  1. VCC  is Connected 5v supply in Arduino.
  2. GND  is Connected ground in Arduino.
  3. Trig.   is Connected Analog1 in Arduino.
  4. Echo.  is Connected Analog2 in Arduino.


  STEP(6)

Servo motor is three terminal VCC, GND, a Control pin.          

  1. VCC  is Connected 5v supply in Arduino.
  2. GND  is Connected ground in Arduino.
  3. Control pin is Connected Digital pin 10. 

                                                                             STEP(7)

Motor Drive is two motors connected output1 and output2.
  1. IN1 is Connected digital pin 7
  2. IN2 is Connected digital pin 6
  3. IN3 is Connected digital pin 5
  4. IN4 is Connected digital pin 4

  STEP(8)

Project Code:-

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
void setup()
{
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}
void demoOne()
{
  // this function will run the motors in both directions at a fixed speed
  // turn on motor A
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enA, 200);
  // turn on motor B
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  // set speed to 200 out of possible range 0~255
  analogWrite(enB, 200);
  delay(2000);
  // now change motor directions
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(2000);
  // now turn off motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}
void demoTwo()
{
  // this function will run the motors across the range of possible speeds
  // note that maximum speed is determined by the motor itself and the operating voltage
  // the PWM values sent by analogWrite() are fractions of the maximum speed possible
  // by your hardware
  // turn on motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  // accelerate from zero to maximum speed
 
 for (int i = 0; i < 256; i++) {
analogWrite(enA, i);
analogWrite(enB, i);
delay(20);
}
// decelerate from maximum speed to zero
for (int i = 255; i > 0; --i)
  {
    analogWrite(enA, i);
    analogWrite(enB, i);
    delay(20);
  }
 
  
  // now turn off motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW); 
}
void loop()
{
  demoOne();
  delay(1000);
  demoTwo();
  delay(1000);
}


Circuit Diagram:-




3 comments: