# How to code a spider robot (four-legged)

Four-legged spider robot

Are you into the fantastic world in the movie Spider-Man: Across the Spider-Verse? Spider-man in the story is really cool.
Are you interested in building a robot of your own? 
This #How to shows you how to build a four-legged spider robot that can walk and rotatewith mBot Mega.

Let's start!

# The first thing to know#

The first thing to know#
Servo

In short, we can send a signal to the servo to tell it how much it should rotate and then stay in that position. However, how does it know where to start turning and how to turn?

We need to make some rules.

Set rules for Servo

Now, let's see how two servos are mounted on one leg of the robot.

Each leg of the robot has two servos.
The "up" servo controls the swing of the upper leg parallel to the ground. The "down" servo controls the swing of the lower leg perpendicular to the ground.

Use mBot mega to code a spider robot

Finally, the robot we build looks like that in the above picture.

For illustration purposes, we name the 8 servos according to their positions (the abbreviations are the names of the servos in the servo variables set of the program).

Four-legged robot

Now, we have a four-legged robot, how do we get it moving?

Imagine how we humans move.
We raise our left leg, step forward, and land on our left foot. Then we raise our right leg, step forward, and land on our right foot.
A four-legged robot moves the same way except that it needs to move two legs at the same time.

Function Design Idea:

Start with the initial angles
Step 1: Lift the front-left and back-right feet
Step 2: Turn the front-left and back-right feet (stepping)
Step 3: Place front-left and back-right feet (landing)
Step 4: Reset the moved front-left and back-right legs to the initial angles
Step 5: Lift the front-right and back-left legs
Step 6: Turn the front-right and back-left legs (stepping)
Step 7: Place the front-right and back-left legs (landing)
Step 8: Reset the moved front-right and back-left legs to the initial angles

# Coding Time #

# Coding Time #
Coding tutorials for spider robotCoding tutorials for spider robot

Think about how to make it go to the left.
We just need to modify the rotation direction of the two legs at Step 2.

Coding tutorials for spider robot

Think about how to make it go to the right.

Coding tutorials for spider robotCoding tutorials for spider robot

Think about how to make it rotate counterclockwise. 

Spider robot transformed from mBot megaSpider robot transformed from mBot mega
# Bring Me Home ^_^ #

# Bring Me Home ^_^ #

mBot Mega remote control robot
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
compatible with raspberry pi for robotics projects and python coding
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
remote control robot for various scenarios
arduino robot kits for inspiring young minds
mBot Mega
mBot Mega remote control robot with bluetooth dongle
mBot Mega remote control robot with battery
mBot Mega remote control robot with remote controller
mBot Mega remote control robot
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
compatible with raspberry pi for robotics projects and python coding
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play
remote control robot for various scenarios
arduino robot kits for inspiring young minds
mBot Mega
mBot Mega remote control robot with bluetooth dongle
mBot Mega remote control robot with battery
mBot Mega remote control robot with remote controller

Makeblock mBot Mega: Smart Remote Control Robot Car for Kids to Learn through Play

$106.99
$129.99
×

Request for Quote

Quotation Notice

1. An email has been sent to you containing the quotation file and all other important files. Please check your mailbox.
2. The quote is valid for 30 days. Please generate your Purchase Order within this period. If the quote expires, a new quote will need to be generated.

Download W9

Download W9

More Support

If you need more help, kindly mail to vendor: us@makeblock.com