BottiMakerRobotics
Published © LGPL

BottiBot

Mini Arduino robot.

IntermediateShowcase (no instructions)5 hours270
BottiBot

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Jumper wires (generic)
Jumper wires (generic)
×1
DC motor (generic)
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Code

Arduino code

Arduino
int enA = 8;
int in1 = 9;
int in2 = 10;
int tt = 2;
// Motor B
 
int enB = 13;
int in3 = 11;
int in4 = 12;

 int trig=6;
 int echo=5;
 int vreme,dinstanca;
void setup()
{
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  pinMode(tt,INPUT);
}
 
void loop()
{
int x = ultrazvucni();
if(x < 5 ) {
  nazad(1000);
  stop1(500);
  levo(600);
  stop1(300);
}
else napred(100);

}

void napred(int vreme){
   digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA, 250);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  analogWrite(enB, 500);
  delay(vreme);
}
void nazad(int vreme){
   digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  analogWrite(enA, 250);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  analogWrite(enB, 500);
  delay(vreme);
}
void stop1(int vreme){
   digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  delay(vreme);
  
}
void levo(int vreme){
   digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA, 250);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  analogWrite(enB, 500);
  delay(vreme);
  
}void desno(int vreme){
   digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  analogWrite(enA, 250);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  analogWrite(enB, 500);
  delay(vreme);
}
int ultrazvucni(){
digitalWrite(trig,LOW);
delayMicroseconds(5);
digitalWrite(trig,HIGH);
delayMicroseconds(5);
digitalWrite(trig,LOW);
vreme=pulseIn(echo,HIGH);
dinstanca=vreme/2/29;
return dinstanca;
}

Credits

Botti

Botti

0 projects • 2 followers
Contact
MakerRobotics

MakerRobotics

6 projects • 87 followers
Contact

Comments