# Alternative Mars Rover Motion Control

Example Description
Learn how to code the Mars Rover to turn left and right on a circle with the set () to () block. Try different left and right orientations and move the Mars Rover with the up and down keys.

#### Introduction

Instead of rotating the Mars Rover at a place to turn left or right, you can alternatives make the Mars Rover move in a circle.

1. Turning left on a circle:
2. Turning right on a circle:
3. Turning right backwards in a circle:
4. Turning left backwards in a circle:

#### Coding Steps

The following code uses the four arrow keys to travel forward (up arrow key), backwards (down arrow key) , forward right in a circle( right arrow key) and forward left in a circle. (left arrow key)

We will also use the keys specially for backward left and right motion. We will use the “a”  key for backward left motion and “d” key for backward right motion.

Make the code and play with the Mars Rover. Try to use different keys and combine different motions.

#### Code

``````sprite=Sprite('Tobi')
import time
quarky = Quarky()
rover = MarsRover(4, 1, 7, 2, 6)
# setwheelsangle(Front Left = 40, Front Right = 40, Back Left = 90, Back Right = 90)
while True:
if sprite.iskeypressed("up arrow"):
rover.home()
rover.setinangle(0)
quarky.runtimedrobot("F",100,2)

if sprite.iskeypressed("down arrow"):
rover.home()
rover.setinangle(0)
quarky.runtimedrobot("B",100,2)

if sprite.iskeypressed("right arrow"):
rover.home()
rover.setrightturnangle(40)
# rover.setwheelsangle(180,180,180,180)
quarky.runtimedrobot("F",100,2)

if sprite.iskeypressed("left arrow"):
rover.home()
rover.setleftturnangle(40)
# rover.setwheelsangle(0,0,0,0)
quarky.runtimedrobot("F",100,2)

if sprite.iskeypressed("A"):
rover.home()
rover.setleftturnangle(40)
quarky.runtimedrobot("B",100,2)

if sprite.iskeypressed("D"):
rover.home()
rover.setrightturnangle(40)
quarky.runtimedrobot("B",100,2)``````

#### Output

Circular Right-Left Motion: