Robotics EveryDay
Published © LGPL

Self Balancing Triangle Robot | Balancing Inverted Triangle

This is the triangle. Which will try to balance itself. With the help of all the sensors & actuators on-board. It is an Inverted Triangle.

BeginnerFull instructions provided4,377
Self Balancing Triangle Robot | Balancing Inverted Triangle

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Breadboard (generic)
Breadboard (generic)
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Scissor, Electrician
Scissor, Electrician

Story

Read more

Custom parts and enclosures

CAD Design For Self Balancing Triangle Robot

Schematics

Circuit Schematic Of Self Balancing Triangle Robot

Code

Code For Self Balancing Robot Triangle

Arduino
#include <Servo.h>
Servo m;

int t = 6;
int e=  7;
double d,dp=0;

void setup() {

  pinMode(t, OUTPUT);  //trigger pin
  pinMode(e, INPUT);  //echo pin
  m.attach(3);       // motor at pin 3

}

int distance(){
  
  long duration, cm;
  
  digitalWrite(t, LOW);
  delayMicroseconds(2);
  digitalWrite(t, HIGH);
  delayMicroseconds(5);
  digitalWrite(t, LOW);  
  duration = pulseIn(e, HIGH);


  cm = duration/ 29 / 2;
  
  return cm; //returns distance in centimeters
}

void loop() {

  d = distance();
  
  if(d<18 && d>0){
    m.write(180 - ((dp*0.95 + d*0.05)*10));
    
  }
  
  dp=d;
  delay(25);
}

Credits

Robotics EveryDay

Robotics EveryDay

0 projects • 9 followers

Comments