Explore Simple 3D Dog Robot and Multiple Servo Motor Control Board

Explore Simple 3D Dog Robot and Multiple Servo Motor Control Board
Explore Simple 3D Dog Robot and Multiple Servo Motor Control Board

Are you ready to take your robotics projects to the next level? Look no further than the simple 3D dog robot. This innovative creation combines the charm of a lovable dog with the power of modern technology, bringing your projects to life in a whole new way.

What Makes the Simple 3D Dog Robot Unique?

The simple 3D dog robot stands out from other robotics projects in a few key ways. First and foremost, its design is captivating. With its lifelike movements and adorable appearance, it’s hard not to fall in love with this little robot.

But the real magic lies in its functionality. The simple 3D dog robot is equipped with multiple servo motors, allowing for precise control over its movements. This means you can program it to walk, turn, wave and even perform tricks. The possibilities are endless!

Understanding the Multiple Servo Motor Control Board

In order to control the movements of the simple 3D dog robot, you’ll need a multiple servo motor control board. This board acts as the brain of the robot, allowing you to send commands and control the servo motors.

The multiple servo motor control board is a small electronic device that connects to your computer or microcontroller. It features multiple ports where you can plug in the servo motors, as well as input and output pins for communication.

With the multiple servo motor control board, you can easily program and control the movements of the simple 3D dog robot.

Getting Started with the Simple 3D Dog Robot and Multiple Servo Motor Control Board

Now that you understand the basics of the simple 3D dog robot and the multiple servo motor control board, it’s time to get started on your own project. Here are a few steps to help you get up and running:

1. Arduino Nano Based Multiple Servo Motor Control Board

Arduino Nano Based Multiple Servo Motor Control Board
Arduino Nano Based Multiple Servo Motor Control Board

I made a board that can control 9 servo motors and you can control them wirelessly with Bluetooth. The board has a special part called an adjustable voltage regulator. It helps adjust the power just right for each servo motor. There’s a knob you can turn to set the power level. Also, there’s a special part called a Schottky diode that helps keep the power steady and reliable, even if there are changes or noise in the power supply.

Two capacitors are also integrated into the circuit. Servo motors can draw significant current during sudden movements, so these capacitors help meet these demands, stabilize the power supply and reduce fluctuations. Each servo motor signal leg is equipped with a resistor for protection. These resistors safeguard the servo motor’s signal leg from overcurrent and harmful voltages by limiting the signal from the microcontroller.

Since both servo motors and the Arduino Nano share the power line, a jumper is included to disconnect the servo motors’ power line during microcontroller programming. Similarly, for the Bluetooth module, a jumper is added to its power input to avoid communication errors during programming by cutting off the Bluetooth power. Additionally, a capacitor is connected to the Arduino Nano VIN supply input to mitigate power fluctuations.

 2. Robot Dog 3D Parts Assembly

You’ll need 4 sets of leg parts since there are 4 legs in total. The parts are easy to put together, but you might want to smooth the joints with a rasp or sandpaper for better movement. I used these tools and found that it made the parts move more smoothly and reduced the strain on the servo motors.

Step 2: Robot Dog 3D Parts Assembly
Step 2: Robot Dog 3D Parts Assembly

Instead of screws, I used quick adhesive to attach the servo motor arms to the legs because I didn’t have the right screws on hand. Be careful not to use too much adhesive! Apply a small amount to the 3D part, then use freeze spray on the servo arm before fitting it into the slot. Let it dry for about 10 seconds. I also applied a tiny bit of adhesive to keep the 3D part joining pins from coming out of the holes.

3. Fixing Servo Motor on the Body

Fixing Servo Motors on the Body
Fixing Servo Motors on the Body

The robot uses 9 MG90S servo motors. These are an advanced version of the widely-used SG90 micro servo motor. Servo motors are popular in robotics because they’re fast and powerful. They’re commonly used in RC cars, airplanes, robot arms, ships and more.

Here are some specs of the Tower Pro MG90S Servo Motor:

  • Operating Voltage: 4.8V – 6V
  • Weight: 13.4 grams
  • Size: Approximately 22.8×12.2×28.5mm
  • No-Load Speed: 0.1 second/60 degrees (at 4.8V), 0.08 second/60 degrees (at 6V)
  • Torque: 1.8 kg.cm (at 4.8V), 2.2 kg.cm (at 6V)
  • Angle Range: 0° – 180° (Standard)
  • Gear: Metal

To assemble the robot, place the servo motors on the body according to the instructions in the video or images. I used the screws that came with the servo motors to attach them securely to the body.

4. Initial Position of Servo Motor

Initial Position of Servo Motors
Initial Position of Servo Motors

After attaching the servos to the body, upload the provided source code to reset all servos to their initial positions before adding the legs. I’ve labeled the servo pins to match the Arduino Nano digital input pins they’re connected to.

Remember, before connecting the board to the USB port, remove the jumpers for SERVO_PWR (Servo motor power) and BLE_PWR (Bluetooth power). Leaving these jumpers in could cause overcurrent issues that might damage your USB port, and the Bluetooth module could interfere with code uploads.

Check the image I shared to see which servo is connected to each leg and their initial positions:

#include <Servo.h>

Servo Leg1F;  //D2 - 80
Servo Leg1B;  //D3 - 100
Servo Leg2F;  //D4 - 100
Servo Leg2B;  //D5 - 80
Servo Leg3F;  //D6 - 80
Servo Leg3B;  //D7 - 100
Servo Leg4F;  //D8 - 100
Servo Leg4B;  //D9 - 80

Servo Headservo;  //D10 - 90

void setup() {
  Leg1F.attach(2);
  Leg1B.attach(3);
  Leg2F.attach(4);
  Leg2B.attach(5);
  Leg3F.attach(6);
  Leg3B.attach(7);
  Leg4F.attach(8);
  Leg4B.attach(9);
  Headservo.attach(10);

  Leg1F.write(80);
  Leg1B.write(100);
  Leg2F.write(100);
  Leg2B.write(80);
  Leg3F.write(80);
  Leg3B.write(100);
  Leg4F.write(100);
  Leg4B.write(80);

  Headservo.attach(90);
}

void loop() {
  // put your main code here, to run repeatedly:

}

  • Leg1F = 80 degrees
  • Leg1B = 100 degrees
  • Leg2F = 100 degrees
  • Leg2B = 80 degrees
  • Leg3F = 80 degrees
  • Leg3B = 100 degrees
  • Leg4F = 100 degrees
  • Leg4B = 80 degrees
  • Headservo = 90 degrees

5. Mounting the Legs to Servos

Mounting the Legs to Servos
Mounting the Legs to Servos

Once you’ve uploaded the code, connect the battery to the circuit (I used 2x 3.7V 18650 Li-Ion Batteries). Then, connect the jumper for SERVO_PWR, and the servo motors should return to their initial positions.

Next, fold both ends of the legs as shown in the image or video. Lay the body on its side and attach it to the servo motor with both ends of the leg at 90 degrees, forming an inverted triangle shape. Be careful as there is still power in the circuit when attaching the legs; this prevents any unwanted movement of the servo positions.

6. Dog Robot Head Assembly

Dog Robot Head Assembly
Dog Robot Head Assembly

Once the legs are assembled, gather the servo motor wires with a cable tie and place the battery in the lower part of the body, securing it in place. Now, let’s attach the dog robot head!

I suggest scaling the 3D head part to 106% before printing so that the HC-SR04 ultrasonic distance sensor and servo arm will fit more comfortably.

Attach the double-ended servo arm to the head using quick adhesive. Then, place the head on the servo on the body and secure the head with the servo motor arm screw.

Currently, the HC-SR04 ultrasonic distance sensor doesn’t have a function. However, I plan to update the robot, project code and mobile application for the distance sensor in the future. That’s why I left plenty of input-output pins for additional sensors on the board.

DogBot Head V1-Part
DogBot Head V1-Part

7. Source Code and Mobile Application

Source Code and Mobile Application
Source Code and Mobile Application

Copy the main application source code shared and open it with the Arduino IDE. Remember to remove the SERVO_PWR and BLE_PWR jumpers before connecting the board to the USB port. Then, connect the board and upload the code.

Next, head to MIT App Inventor, a free platform for creating mobile applications. 

Finally, create the Android App (.apk) file from the Build tab. You can choose to download the file or scan the code for installation.

#include <Servo.h>

Servo Leg1F;
Servo Leg1B;
Servo Leg2F;
Servo Leg2B;
Servo Leg3F;
Servo Leg3B;
Servo Leg4F;
Servo Leg4B;
Servo Headservo;

boolean stringComplete = false;
boolean stopcmd = false;
String inputString;

int selservo;
int rotate1;
int rotate2;
int rotate3;
int rotate4;

int leftdistance;
int rightdistance;

float LALeg1F;
float LALeg1B;
float LALeg2F;
float LALeg2B;
float LALeg3F;
float LALeg3B;
float LALeg4F;
float LALeg4B;
float LAHeadservo;

boolean autorun;
int autostep;
boolean fromauto;
boolean smoothrun;
int smoothdelay;
int maxstep = 0;
int totalforwardsteps = 50;
int totalsidesteps = 25;
int moveforwardsteps = 0;
int movesidesteps = 0;
int forwardsteps = 0;

float stepLeg1F;
float stepLeg1B;
float stepLeg2F;
float stepLeg2B;
float stepLeg3F;
float stepLeg3B;
float stepLeg4F;
float stepLeg4B;

int TOLeg1F;
int TOLeg1B;
int TOLeg2F;
int TOLeg2B;
int TOLeg3F;
int TOLeg3B;
int TOLeg4F;
int TOLeg4B;
int TOHeadservo;

int trigPin = A2;  //tigg
int echoPin = A3;  //echo
long duration, distance;

int walkF[][7] = { { 124, 146, 177, 150, 132, 115, 115 }, { 94, 132, 178, 139, 112, 84, 84 }, { 37, 112, 179, 139, 95, 42, 42 }, { 22, 95, 150, 115, 78, 30, 30 }, { 11, 78, 124, 92, 59, 13, 13 }, { 13, 59, 92, 58, 36, 2, 2 } };
int walkB[][7] = { { 3, 34, 56, 65, 48, 30, 30 }, { 2, 48, 86, 96, 68, 41, 41 }, { 1, 68, 143, 138, 85, 41, 41 }, { 30, 85, 158, 150, 102, 65, 65 }, { 56, 102, 169, 167, 121, 88, 88 }, { 88, 121, 167, 178, 144, 122, 122 } };

int walkH[] = { 3, 4, 5, 6, 7, 8 };
int Fheight;
int Bheight;
int heightchange;

int walkstep;
int walkstep2;

int Twalkstep;
int Twalkstep2;

String S1;
String S2;
String Splitstr;
int Sstr1;
int Sstr2;
int findcomma;
int previouscomma;
String reccmd;
String othercmd;

void setup() {
  pinMode(echoPin, INPUT);
  pinMode(trigPin, OUTPUT);

  LALeg1F = 80;
  LALeg1B = 100;
  LALeg2F = 100;
  LALeg2B = 80;
  LALeg3F = 80;
  LALeg3B = 100;
  LALeg4F = 100;
  LALeg4B = 80;
  LAHeadservo = 90;

  TOLeg1F = LALeg1F;
  TOLeg1B = LALeg1B;
  TOLeg2F = LALeg2F;
  TOLeg2B = LALeg2B;
  TOLeg3F = LALeg3F;
  TOLeg3B = LALeg3B;
  TOLeg4F = LALeg4F;
  TOLeg4B = LALeg4B;
  TOHeadservo = LAHeadservo;

  Leg1F.attach(2);
  Leg1B.attach(3);
  Leg2F.attach(4);
  Leg2B.attach(5);
  Leg3F.attach(6);
  Leg3B.attach(7);
  Leg4F.attach(8);
  Leg4B.attach(9);
  Headservo.attach(10);
  delay(1000);
  Servomovement();

  Serial.begin(9600);
  walkstep = 1;
  Fheight = 5;
  Bheight = 5;
  reccmd = "S";
  autorun = false;
  fromauto = false;
  smoothrun = true;
  smoothdelay = 2;
  delay(2000);
}

void loop() {
  if (autorun == true) {
    if (fromauto == false) {
      fromauto = true;
    }
    if (autostep == 0) {
      Fheight = 5;
      Bheight = 5;
      autostep = 1;
      forwardsteps = 0;
      changeheight();
    } else if (autostep == 1) {
      Distancecal();
      if (distance < 8) {
        reccmd = "S";
        autostep = 2;
      } else {
        reccmd = "F";
      }


      if (Fheight != 5) {
        moveforwardsteps = moveforwardsteps + 1;
        if (moveforwardsteps > totalforwardsteps) {
          Fheight = 5;
          Bheight = 5;
          autostep = 1;
        }
      }
    } else if (autostep == 2) {
      if (Fheight >= 1) {
        Fheight = Fheight - 1;
        Bheight = Bheight - 1;
        changeheight();
        Distancecal();
        if (distance >= 5) {
          forwardsteps = 0;
          moveforwardsteps = 0;
          autostep = 1;
        }
      } else {
        Fheight = 5;
        Bheight = 5;
        autostep = 3;
        changeheight();
      }
    } else if (autostep == 3) {
      smoothdelay = 8;
      TOHeadservo = 0;
      Servomovement();
      Distancecal();
      delay(100);
      rightdistance = distance;
      TOHeadservo = 180;
      Servomovement();
      Distancecal();
      delay(100);
      leftdistance = distance;
      TOHeadservo = 90;
      Servomovement();
      smoothdelay = 2;
      if (leftdistance > rightdistance) {
        reccmd = "L";
      } else {
        reccmd = "R";
      }
      movesidesteps = 0;
      autostep = 4;
    } else if (autostep == 4) {
      movesidesteps = movesidesteps + 1;
      if (movesidesteps > totalsidesteps) {
        autostep = 1;
      }
    }
  } else if (fromauto == true) {
    Fheight = 5;
    Bheight = 5;
    reccmd = "S";
    changeheight();
    fromauto = false;
  }

  if (reccmd == "F" || reccmd == "B" || reccmd == "L" || reccmd == "R" || reccmd == "G" || reccmd == "I" || reccmd == "H" || reccmd == "J") {
    if (reccmd == "F" || reccmd == "L" || reccmd == "G" || reccmd == "I") {
      walkstep = walkstep + 1;
      if (walkstep > 7) {
        walkstep = 1;
      }
      walkstep2 = walkstep + 3;
      if (walkstep2 > 7) {
        walkstep2 = walkstep2 - 7;
      }
    } else if (reccmd == "B" || reccmd == "R" || reccmd == "H" || reccmd == "J") {
      walkstep = walkstep - 1;
      if (walkstep < 1) {
        walkstep = 7;
      }
      walkstep2 = walkstep - 4;
      if (walkstep2 < 1) {
        walkstep2 = walkstep2 + 7;
      }
    }

    if (reccmd == "F" || reccmd == "B") {

      rotate1 = walkF[Fheight][walkstep - 1];
      rotate2 = walkB[Fheight][walkstep - 1];
      rotate3 = walkF[Bheight][walkstep - 1];
      rotate4 = walkB[Bheight][walkstep - 1];

      TOLeg1F = rotate1;
      TOLeg1B = rotate2;
      TOLeg4F = 180 - rotate3;
      TOLeg4B = 180 - rotate4;
      Servomovement();

      rotate1 = walkF[Fheight][walkstep2 - 1];
      rotate2 = walkB[Fheight][walkstep2 - 1];
      rotate3 = walkF[Bheight][walkstep2 - 1];
      rotate4 = walkB[Bheight][walkstep2 - 1];

      TOLeg2F = 180 - rotate1;
      TOLeg2B = 180 - rotate2;
      TOLeg3F = rotate3;
      TOLeg3B = rotate4;
      Servomovement();

    } else if (reccmd == "G" || reccmd == "I" || reccmd == "H" || reccmd == "J") {
      if (reccmd == "I" and walkstep >= 4) {
        rotate1 = walkF[Fheight][4];
        rotate2 = walkB[Fheight][4];
      } else {
        rotate1 = walkF[Fheight][walkstep - 1];
        rotate2 = walkB[Fheight][walkstep - 1];
      }

      if (reccmd == "H" and walkstep >= 4) {
        rotate3 = walkF[Bheight][4];
        rotate4 = walkB[Bheight][4];
      } else {
        rotate3 = walkF[Bheight][walkstep - 1];
        rotate4 = walkB[Bheight][walkstep - 1];
      }

      TOLeg1F = rotate1;
      TOLeg1B = rotate2;
      TOLeg4F = 180 - rotate3;
      TOLeg4B = 180 - rotate4;
      Servomovement();

      if (reccmd == "G" and walkstep2 >= 4) {
        rotate1 = walkF[Fheight][4];
        rotate2 = walkB[Fheight][4];
      } else {
        rotate1 = walkF[Fheight][walkstep2 - 1];
        rotate2 = walkB[Fheight][walkstep2 - 1];
      }

      if (reccmd == "J" and walkstep2 >= 4) {
        rotate3 = walkF[Bheight][4];
        rotate4 = walkB[Bheight][4];
      } else {
        rotate3 = walkF[Bheight][walkstep2 - 1];
        rotate4 = walkB[Bheight][walkstep2 - 1];
      }

      TOLeg2F = 180 - rotate1;
      TOLeg2B = 180 - rotate2;
      TOLeg3F = rotate3;
      TOLeg3B = rotate4;
      Servomovement();

    } else if (reccmd == "L" || reccmd == "R") {
      rotate1 = walkF[Fheight][walkstep - 1];
      rotate2 = walkB[Fheight][walkstep - 1];
      rotate3 = walkF[Bheight][walkstep - 1];
      rotate4 = walkB[Bheight][walkstep - 1];

      TOLeg1F = rotate1;
      TOLeg1B = rotate2;
      TOLeg4F = rotate4;
      TOLeg4B = rotate3;
      Servomovement();

      rotate1 = walkF[Fheight][(8 - walkstep) - 1];
      rotate2 = walkB[Fheight][(8 - walkstep) - 1];
      rotate3 = walkF[Bheight][(8 - walkstep) - 1];
      rotate4 = walkB[Bheight][(8 - walkstep) - 1];

      TOLeg2F = 180 - rotate1;
      TOLeg2B = 180 - rotate2;
      TOLeg3F = 180 - rotate4;
      TOLeg3B = 180 - rotate3;
      Servomovement();
    }

    delay(100);

    if (stopcmd == true) {
      if (walkstep == 4) {
        reccmd = "S";
        stopcmd = false;
      }
    }
    if (heightchange != 0 && walkstep == 4) {
      changeheight();
    }
  } else if (heightchange != 0) {
    changeheight();
  } else if (reccmd == "C") {
    smoothdelay = 8;
    selfcheck();
    smoothdelay = 2;
    reccmd = "S";
  } else if (reccmd == "V") {
    sayhai();
    reccmd = "S";
  }
}

void sayhai() {
  TOLeg1F = 0;
  TOLeg1B = 180;
  TOLeg2F = 180;
  TOLeg2B = 0;
  TOLeg3F = 180;
  TOLeg3B = 0;
  TOLeg4F = 0;
  TOLeg4B = 180;
  TOHeadservo = 90;
  Servomovement();

  for (int i = 1; i <= 5; i++) {
    delay(500);
    TOLeg1F = 60;
    TOHeadservo = 135;
    Servomovement();

    delay(500);
    TOLeg1F = 100;
    TOHeadservo = 45;
    Servomovement();
  }
  TOLeg1F = 0;
  TOHeadservo = 90;
  Servomovement();
}

void selfcheck() {
  TOLeg1F = 0;
  TOLeg1B = 180;
  TOLeg2F = 180;
  TOLeg2B = 0;
  TOLeg3F = 0;
  TOLeg3B = 180;
  TOLeg4F = 180;
  TOLeg4B = 0;
  TOHeadservo = 90;
  Servomovement();

  delay(500);
  TOLeg1F = 180;
  TOLeg1B = 0;
  Servomovement();

  delay(500);
  TOLeg1F = 0;
  TOLeg1B = 180;
  Servomovement();

  delay(500);
  TOLeg2F = 0;
  TOLeg2B = 180;
  Servomovement();

  delay(500);
  TOLeg2F = 180;
  TOLeg2B = 0;
  Servomovement();

  delay(500);
  TOLeg3F = 180;
  TOLeg3B = 0;
  Servomovement();

  delay(500);
  TOLeg3F = 0;
  TOLeg3B = 180;
  Servomovement();

  delay(500);
  TOLeg4F = 0;
  TOLeg4B = 180;
  Servomovement();

  delay(500);
  TOLeg4F = 180;
  TOLeg4B = 0;
  Servomovement();

  TOHeadservo = 0;
  Servomovement();
  delay(100);
  TOHeadservo = 180;
  Servomovement();
  delay(100);
  TOHeadservo = 90;
  Servomovement();
  delay(100);
}

void changeheight() {
  if (othercmd == "O") {
    Fheight = 5;
    Bheight = 5;
  } else if (othercmd == "P") {
    Fheight = 0;
    Bheight = 0;
  }

  if (othercmd == "D" || othercmd == "U" || othercmd == "W" || othercmd == "Y") {
    Fheight = Fheight + heightchange;
    if (Fheight > 5) {
      Fheight = 5;
    }
    if (Fheight < 0) {
      Fheight = 0;
    }
  }
  if (othercmd == "D" || othercmd == "U" || othercmd == "X" || othercmd == "Z") {
    Bheight = Bheight + heightchange;
    if (Bheight > 5) {
      Bheight = 5;
    }
    if (Bheight < 0) {
      Bheight = 0;
    }
  }
  heightchange = 0;

  rotate1 = walkF[Fheight][4];
  rotate2 = walkB[Fheight][4];
  TOLeg1F = rotate1;
  TOLeg1B = rotate2;
  TOLeg2F = 180 - rotate1;
  TOLeg2B = 180 - rotate2;

  rotate1 = walkF[Bheight][4];
  rotate2 = walkB[Bheight][4];
  TOLeg3F = rotate1;
  TOLeg3B = rotate2;
  TOLeg4F = 180 - rotate1;
  TOLeg4B = 180 - rotate2;
  Servomovement();
}
void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == 'A') {
      inputString = "";
      autorun = true;
      autostep = 0;
    } else if (inChar == 'M') {
      inputString = "";
      autorun = false;
    }

    if (autorun == false) {
      if (inChar == 'F' || inChar == 'B' || inChar == 'L' || inChar == 'R' || inChar == 'G') {
        inputString = "";
        reccmd = inChar;
      } else if (inChar == 'S') {
        inputString = "";
        stopcmd = true;
      } else if (inChar == 'C' || inChar == 'V') {
        inputString = "";
        reccmd = inChar;
      } else if (inChar == 'U' || inChar == 'O') {
        inputString = "";
        othercmd = inChar;
        heightchange = 1;
      } else if (inChar == 'D' || inChar == 'P') {
        inputString = "";
        othercmd = inChar;
        heightchange = -1;
      } else if (inChar == 'W' || inChar == 'X') {
        inputString = "";
        othercmd = inChar;
        heightchange = -1;
      } else if (inChar == 'Y' || inChar == 'Z') {
        inputString = "";
        othercmd = inChar;
        heightchange = 1;
      }
    } else {
      inputString = "";
    }
  }
}

void Servomovement() {
  if (smoothrun == true) {
    smoothmove();
  }

  LALeg1F = TOLeg1F;
  LALeg1B = TOLeg1B;
  LALeg2F = TOLeg2F;
  LALeg2B = TOLeg2B;
  LALeg3F = TOLeg3F;
  LALeg3B = TOLeg3B;
  LALeg4F = TOLeg4F;
  LALeg4B = TOLeg4B;
  LAHeadservo = TOHeadservo;

  Leg1F.write(TOLeg1F);
  Leg1B.write(TOLeg1B);
  Leg2F.write(TOLeg2F);
  Leg2B.write(TOLeg2B);
  Leg3F.write(TOLeg3F);
  Leg3B.write(TOLeg3B);
  Leg4F.write(TOLeg4F);
  Leg4B.write(TOLeg4B);
  Headservo.write(TOHeadservo);
}

void smoothmove() {
  maxstep = 0;
  if (abs(LALeg1F - TOLeg1F) > maxstep) {
    maxstep = abs(LALeg1F - TOLeg1F);
  }
  if (abs(LALeg1B - TOLeg1B) > maxstep) {
    maxstep = abs(LALeg1B - TOLeg1B);
  }
  if (abs(LALeg2F - TOLeg2F) > maxstep) {
    maxstep = abs(LALeg2F - TOLeg2F);
  }
  if (abs(LALeg2B - TOLeg2B) > maxstep) {
    maxstep = abs(LALeg2B - TOLeg2B);
  }
  if (abs(LALeg3F - TOLeg3F) > maxstep) {
    maxstep = abs(LALeg3F - TOLeg3F);
  }
  if (abs(LALeg3B - TOLeg3B) > maxstep) {
    maxstep = abs(LALeg3B - TOLeg3B);
  }
  if (abs(LALeg4F - TOLeg4F) > maxstep) {
    maxstep = abs(LALeg4F - TOLeg4F);
  }
  if (abs(LALeg4B - TOLeg4B) > maxstep) {
    maxstep = abs(LALeg4B - TOLeg4B);
  }
  if (maxstep > 0) {
    stepLeg1F = (TOLeg1F - LALeg1F) / maxstep;
    stepLeg1B = (TOLeg1B - LALeg1B) / maxstep;
    stepLeg2F = (TOLeg2F - LALeg2F) / maxstep;
    stepLeg2B = (TOLeg2B - LALeg2B) / maxstep;
    stepLeg3F = (TOLeg3F - LALeg3F) / maxstep;
    stepLeg3B = (TOLeg3B - LALeg3B) / maxstep;
    stepLeg4F = (TOLeg4F - LALeg4F) / maxstep;
    stepLeg4B = (TOLeg4B - LALeg4B) / maxstep;
    for (int i = 0; i <= maxstep; i += 1) {
      LALeg1F = LALeg1F + stepLeg1F;
      LALeg1B = LALeg1B + stepLeg1B;
      LALeg2F = LALeg2F + stepLeg2F;
      LALeg2B = LALeg2B + stepLeg2B;
      LALeg3F = LALeg3F + stepLeg3F;
      LALeg3B = LALeg3B + stepLeg3B;
      LALeg4F = LALeg4F + stepLeg4F;
      LALeg4B = LALeg4B + stepLeg4B;
      Leg1F.write(LALeg1F);
      Leg1B.write(LALeg1B);
      Leg2F.write(LALeg2F);
      Leg2B.write(LALeg2B);
      Leg3F.write(LALeg3F);
      Leg3B.write(LALeg3B);
      Leg4F.write(LALeg4F);
      Leg4B.write(LALeg4B);
      delay(smoothdelay);
    }
  }

  if (LAHeadservo > TOHeadservo) {
    for (int i = LAHeadservo; i >= TOHeadservo; i -= 1) {
      LAHeadservo = i;
      Headservo.write(LAHeadservo);
      delay(smoothdelay);
    }
  } else {
    for (int i = LAHeadservo; i <= TOHeadservo; i += 1) {
      LAHeadservo = i;
      Headservo.write(LAHeadservo);
      delay(smoothdelay);
    }
  }
}

void Distancecal() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;
}

8. Launch the APP and Move the Robot Dog

Launch the App and Move the Dog Robot
Launch the App and Move the Dog Robot

After you’ve uploaded the code and installed the application, reconnect the board’s power jumpers. Turn on the Bluetooth connection on your Android device and pair it with the Bluetooth module named HC-06x from the list. It might prompt you for a password during pairing, typically the default password is 1234 (or 0000). Then, open the Dog Robot app, list the Bluetooth devices, find the Bluetooth module in the list, and select it.

If the connection is successful, the application will switch to the control interface. Now you can move your dog robot around and even make it say “Hi!”

Thanks for reading!

By Anshul Pal

Hey there, I'm Anshul Pal, a tech blogger and Computer Science graduate. I'm passionate about exploring tech-related topics and sharing the knowledge I've acquired. With two years of industry expertise in blogging and content writing. Thanks for reading my blog – Happy Learning!

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.