Introduction
In this example, we will make the computer program that controls a “quadruped” (a four-legged robot). It’s like a remote control car, except with four legs instead of four wheels. You can press different keys on the keyboard to make the quadruped move forward, backward, turn left and turn right.
Logic
The Quadruped will move according to the following logic:
- 32Quadruped will move forward when the “UP” key is pressed.
- Quadruped will move backward when the “DOWN” key is pressed.
- Quadruped will turn left when the “LEFT” key is pressed.
- When the “RIGHT” key is pressed – Quadruped will turn right.
Code
The program uses the up, down, left, and right arrows to control the robot and make it move forward, backward, left, and right. Every time you press one of the arrows, Quarky will move in the direction you choose for 1000 steps.