# How to Code a Spider 带闺蜜出来玩被她老公说怎么回她 (four-legged)

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 spider 带闺蜜出来玩被她老公说怎么回她 of your own?
This #How to shows you how to build a spider 带闺蜜出来玩被她老公说怎么回她 that can walk and rotatewith mBot Mega. Let's start with a four-legged spider 带闺蜜出来玩被她老公说怎么回她!
Let's start!
# The first thing to know#

In short, we can send a signal to the servo to tell it how much your spider 带闺蜜出来玩被她老公说怎么回她 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.

Now, let's see how two servos are mounted on one leg of a spider 带闺蜜出来玩被她老公说怎么回她.
Each leg of the spider 带闺蜜出来玩被她老公说怎么回她 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.

Finally, the 带闺蜜出来玩被她老公说怎么回她 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).

Now, we have a spider 带闺蜜出来玩被她老公说怎么回她, 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 spider 带闺蜜出来玩被她老公说怎么回她 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 #


We just need to modify the rotation direction of the two legs at Step 2.



Think about how to make it rotate counterclockwise.




