Min menu

Pages

Project 35 : car robot using Arduino

 

Simple robot using arduino 

How often have we wished to have a robot that circumvents the house staying away from snags? Making this undertaking with Arduino Uno, a HC-SR04 module and two wheels will take us to be a kid. 



The robot can maintain a strategic distance from deterrents, because of the ultrasonic reach locater sensor that detects snag going ahead its way. The robot is outfitted with two engines. When it sees a deterrent in its way, it blocks one of the two wheels, subsequently permitting to pivot and abstain from knocking. 


There are a few robot case accessible on Ebay. You can purchase something like demonstrated as follows:





To begin with, we mount the circuit like the accompanying chart, in the event that you don't utilize the BC547B semiconductors and need to utilize different sorts of semiconductors I recommend you investigate the datasheet of the segment you will utilize. You should think about the subtleties and utilize a reasonable one. 


In the wake of having collected the parts on the breadboard and associated everything, all that remains is to embed the sketch on Arduino through the IDE refreshed to the most recent adaptation. The code is as per the following:

Code


int MOTORD = 8;
 int MOTORS = 9;
#define echoPin 2 // Pin that receives the echo pulse
#define trigPin 3

void setup () {
  Serial.begin (9600);
pinMode (MOTORD, OUTPUT);
pinMode (MOTORS, OUTPUT);
pinMode (echoPin, INPUT); // septum echopin as input
pinMode (trigPin, OUTPUT); // sect trigger as output
}
void loop () {
  
  
  digitalWrite (trigPin, LOW);
  delayMicroseconds (2);
  digitalWrite (trigPin, HIGH);
  delayMicroseconds (10);
  digitalWrite (trigPin, LOW);
  int distance = pulseIn (echoPin, HIGH);
  distance = distance / 58;
   Serial.println (distance);
   // if I have an obstacle 25 cm away, turn right and keep the right wheel still
  if ((distance<25)&&(distance != 0)) {// sometimes zeroes arrive and those I don't have to take them into consideration
  digitalWrite (MOTORS, HIGH); // I turn on one engine and turn off the other so I can turn
  digitalWrite (MOTORD, LOW);
  delay (500);
  }
   else {// go straight
  digitalWrite (MOTORS, HIGH);
  digitalWrite (MOTORD, HIGH);
  
  }
  
}


reaction: