Project 17: Arduino 3rd Printed Biped Robot Walking & Dancing
Main Ideas:
In this project we have used 3rd printed parts to build bipedal
walking robot is a type of humanoid robot
, Arduino Nano board was used as it need small board to put it inside
the robot body, and we have used the Ultra Sonic HC-SR04 Sensor connected to the robot body to be used for object
detecting, so it will check if any obstacle to avoid them. We have programed
the robot to do different activities i.e. walk, move back and dancing.
Circuit / Parts
·
Ultra Sonic HC-SR04 Sensor
·
4 Servo Motors
·
Arduino Nano
·
9 Volt battery
·
3rd printed parts refer
to below link
https://www.myminifactory.com/object/3d-print-bob-the-biped-robot-2759#
#include <VarSpeedServo.h> #include <Ultrasonic.h> Ultrasonic ultrasonic(11, 12, 10000UL); // (Trig
PIN,Echo PIN) Echo PIN:12 orange wire, Trig PIN=11 yellow Wire //Left Hip motor 110 VarSpeedServo LeftHipmotor; //Right Hip motor 100 VarSpeedServo RightHipmotor; //Right Ankle Motor 90 VarSpeedServo RightAnklemotor; //Left Ankle Motor 80 VarSpeedServo LeftAnklemotor; /*CONNECTION DETIALS Servo1
-> pin 3 of arduino Nano Left Hip motor Servo2
-> pin 5 of arduino Nano Right Hip motor Servo4
-> pin 9 of arduino Nano Right Ankle Motor Servo5
-> pin 10 of arduino Nano Left Ankle Motor */ const int LeftHipmotorpin = 3; // the digital pin used for the servo const int RightHipmotorpin = 5; // the digital pin used for the servo const int RightAnklemotorpin = 9; // the digital pin used for the servo const int LeftAnklemotorpin = 10; // the digital pin used for the servo float distanceCmFront; int ultrastoplimit = 20; // define when to stop int ultrareducespeedlimit = 40; //define when to
reduce speed int currentStatus; /*CONNECTION DETIALS Servo1
-> pin 3 of arduino Nano Left Hip motor Servo2
-> pin 5 of arduino Nano Right Hip motor Servo4
-> pin 9 of arduino Nano Right Ankle Motor Servo5
-> pin 10 of arduino Nano Left Ankle Motor */ int count = 0; // save the time that we started
moveback int movetype = 0; //=0 walk =1 new move , =2 ankel,
=3 ankel1 void setup() { Serial.begin(9600); // put your
setup code here, to run once:
distanceCmFront = 0; //**Initial
position of all four servo motors**// /*
servo1.write(110);
servo2.write(100);
servo4.write(90);
servo5.write(80); */
//**inititialised**// set_ini(); } void loop() { count =
count + 1;
Serial.println (count); if (count
>= 15) { stopm();
delay(2000);
ScanUltrasonicFront (); count = 0; movetype =
movetype + 1; //=0 walk =1 ankel , =2 new move , =3 ankel1 if
(movetype > 3) { movetype
= 0; } } Serial.print
(" current move :");
Serial.println (movetype); if (movetype
== 0) { walk(); } else if
(movetype == 1) {
new_move_ankel();
new_move(); } else if
(movetype == 2) {
new_move(); } else if
(movetype == 2) {
new_move_ankel1(); } } void new_move() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
LeftHipmotor.write(145, 55, true);
RightHipmotor.write(130, 55, true); delay(50);
LeftHipmotor.write(110, 55, true);
RightHipmotor.write(100, 55, true); } void new_move_ankel() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
RightAnklemotor.write(90, 50, true);
LeftAnklemotor.write(80, 50, true); delay(50);
RightAnklemotor.write(70, 50, true);
LeftAnklemotor.write(60, 50, true); } void new_move_ankel1() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
RightAnklemotor.write(90, 30, true);
LeftAnklemotor.write(80, 30, true); delay(50);
RightAnklemotor.write(110, 30, true);
LeftAnklemotor.write(60, 30, true); } void walk() {
lef_up_rev(); delay(10); right_up(); delay(10); set_ini(); } void set_ini() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
LeftHipmotor.write(110, 50, true);
RightHipmotor.write(100, 50, true);
RightAnklemotor.write(90, 50, true);
LeftAnklemotor.write(80, 50, true); } void stopm() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
LeftHipmotor.write(110, 50, true);
RightHipmotor.write(100, 50, true);
RightAnklemotor.write(90, 50, true);
LeftAnklemotor.write(80, 50, true);
LeftHipmotor.detach();
RightHipmotor.detach();
RightAnklemotor.detach();
LeftAnklemotor.detach(); delay (500); } void lef_up_rev() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not) LeftAnklemotor.write(100,
55, true);
RightAnklemotor.write(100, 55, true); delay(10);
RightHipmotor.write(130, 55, true); delay(10);
//RightAnklemotor.write(90, 50, true); } void lef_up() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
LeftAnklemotor.write(60, 55, true);
RightAnklemotor.write(80, 55, true); delay(10);
RightHipmotor.write(60, 55, true); delay(10);
//RightAnklemotor.write(90, 50, true); } void right_up_rev() { // LeftHipmotor.write(110, 50, true); // RightHipmotor.write(100, 50, true); // RightAnklemotor.write(90, 50, true); // LeftAnklemotor.write(80, 50, true);
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not) RightAnklemotor.write(110,
55, true);
LeftAnklemotor.write(100, 55, true); delay(10);
LeftHipmotor.write(90, 55, true); delay(10);
//LeftAnklemotor.write(80, 50, true); } void right_up() {
LeftHipmotor.attach(LeftHipmotorpin);
RightHipmotor.attach(RightHipmotorpin);
RightAnklemotor.attach(RightAnklemotorpin);
LeftAnklemotor.attach(LeftAnklemotorpin); //(postion ,
speed , sync or not)
RightAnklemotor.write(70, 55, true);
LeftAnklemotor.write(60, 55, true); delay(10);
LeftHipmotor.write(145, 55, true); delay(10);
//LeftAnklemotor.write(80, 50, true); } void ScanUltrasonicFront () {
distanceCmFront = ultrasonic.read(CM);
Serial.print(distanceCmFront); // CM or INC
Serial.println(" cm Down" ); delay(10); } |