Mars Rover – Piper

MARS ROVER

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Let's make a rover!

To get started, head to Piper Make and hit this icon:

Time: 60 minutes

Age Range: 8+

Difficulty: Advanced

This project combines assembling, wiring, and programming a wheeled rover. The final step challenges students to create programs that make the rover drive in different shapes.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Practice breadboarding and wiring.
  • Review and understand computational concepts of:
    • loops: running the same sequence multiple times.
    • sequence: identifying a series of steps for a task
  • Demonstrate computational thinking core concepts, including:
    • Algorithm Design by creating an ordered series of instructions for solving similar problems or for doing a task, such as turning a light off and on in the right order.
  • Create programs that include events, loops, and variables.
  • Decompose problems into smaller, manageable tasks which may themselves be decomposed.
  • Test and debug a program or algorithm to ensure it accomplishes the intended task.
  • Perform different roles when collaborating with peers during the design, implementation, and review stages of program development.

STANDARDS ALIGNMENT

CSTA's K-12 Standards 

1B-CS-02: Model how computer hardware and software work together as a system to accomplish tasks. Subconcept: Hardware & Software; Practice 4.4

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-13: Use an iterative process to plan the development of a program by including others’ perspectives and considering user preferences. Subconcept: Program Development; Practice 1.1, 5.1

1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2  

1B-AP-16: Take on varying roles, with teacher guidance, when collaborating with peers during the design, implementation, and review stages of program development. Subconcept: Program Development; Practice 2.2

CCSS ELA

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

World-Class Instructional Design and Assessment (WIDA) English Language Proficiency Standards

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

California's K-12 Computer Science Standards

3-5.CS.2: Demonstrate how computer hardware and software work together as a system to accomplish tasks.

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

3-5.AP.15: Use an iterative process to plan and develop a program by considering the perspectives and preferences of others.

3-5.AP.17: Test and debug a program or algorithm to ensure it accomplishes the intended task.

3-5.AP.18: Perform different roles when collaborating with peers during the design, implementation, and review stages of program development.

Common Core English Language Arts

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

California English Language Development Standards

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

Michigan Integrated Technology Competencies for Students (MITECS)

1B-CS-02: Model how computer hardware and software work together as a system to accomplish tasks. Subconcept: Hardware & Software; Practice 4.4

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-13: Use an iterative process to plan the development of a program by including others’ perspectives and considering user preferences. Subconcept: Program Development; Practice 1.1, 5.1

1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2  

1B-AP-16: Take on varying roles, with teacher guidance, when collaborating with peers during the design, implementation, and review stages of program development. Subconcept: Program Development; Practice 2.2

Michigan English Language Arts

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA English Language Development

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

Science Texas Essential Knowledge & Skills Grade 3

(b)(2) Scientific investigation and reasoning. The student uses scientific practices during laboratory and outdoor investigations. The student is expected to:
(A) plan and implement descriptive investigations, including asking and answering questions, making inferences, and selecting and using equipment or technology needed, to solve a specific problem in the natural world;

(b)(3) Scientific investigation and reasoning. The student knows that information, critical thinking, scientific problem solving, and the contributions of scientists are used in making decisions.

Science Texas Essential Knowledge & Skills Grade 4

(a)(1)(A) Within the physical environment, students know about the physical properties of matter including mass, volume, states of matter, temperature, magnetism, and the ability to sink or float. Students will differentiate among forms of energy including mechanical, light, sound, and thermal energy. Students will explore electrical circuits and design descriptive investigations to explore the effect of force on objects.

(b)(3) Scientific investigation and reasoning. The student uses critical thinking and scientific problem solving to make informed decisions. The student is expected to:

    (A) analyze, evaluate, and critique scientific explanations by using evidence, logical reasoning, and experimental and observational testing;

    (B) represent the natural world using models such as the water cycle and stream tables and identify their limitations, including accuracy and size; and

    (C) connect grade-level appropriate science concepts with the history of science, science careers, and contributions of scientists.

Science Texas Essential Knowledge & Skills Grade 5

(a)(1) In Grade 5, scientific investigations are used to learn about the natural world. Students should understand that certain types of questions can be answered by investigations and that methods, models, and conclusions built from these investigations change as new observations are made. Models of objects and events are tools for understanding the natural world and can show how systems work. They have limitations and based on new discoveries are constantly being modified to more closely reflect the natural world.

(a)(3) Recurring themes are pervasive in sciences, mathematics, and technology. These ideas transcend disciplinary boundaries and include patterns, cycles, systems, models, and change and constancy.

ELA Texas Essential Knowledge & Skills Grade 3

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) speak coherently about the topic under discussion, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively;

    (D) work collaboratively with others by following agreed-upon rules, norms, and protocols; and

    (E) develop social communication such as conversing politely in all situations.

ELA Texas Essential Knowledge & Skills Grades 4 & 5

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) express an opinion supported by accurate information, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively; and

    (D) work collaboratively with others to develop a plan of shared responsibilities.

(b)(13) Inquiry and research: listening, speaking, reading, writing, and thinking using multiple texts. The student engages in both short-term and sustained recursive inquiry processes for a variety of purposes. The student is expected to:

    (A) generate and clarify questions on a topic for formal and informal inquiry;

    (B) develop and follow a research plan with adult assistance;

    (C) identify and gather relevant information from a variety of sources;

    (D) understand credibility of primary and secondary sources;

    (E) demonstrate understanding of information gathered;

    (F) differentiate between paraphrasing and plagiarism when using source materials;

    (G) develop a bibliography; and

    (H) use an appropriate mode of delivery, whether written, oral, or multimodal, to present results.

§74.4. English Language Proficiency Standards

(c) Cross-curricular second language acquisition essential knowledge and skills.

(3) Cross-curricular second language acquisition/speaking.

(D) speak using grade-level content area vocabulary in context to internalize new English words and build academic language proficiency;

(E) share information in cooperative learning interactions;

(F) ask and give information ranging from using a very limited bank of high-frequency, high-need, concrete vocabulary, including key words and expressions needed for basic communication in academic and social contexts, to using abstract and content-based vocabulary during extended speaking assignments;

(G) express opinions, ideas, and feelings ranging from communicating single words and short phrases to participating in extended discussions on a variety of social and grade-appropriate academic topics;

(H) narrate, describe, and explain with increasing specificity and detail as more English is acquired;

CONCEPTS

Students will apply their knowledge of wiring and coding to create a rover.

PARTS

GPIO SETUP

OVERVIEW OF STEPS

Step 1: Let's make a rover!

Robots are cool, right? In this tutorial, we are going to make a small robot that can drive around and help us explore Mars!

Step 2: Collect your Materials

You'll also need:

  • 2 wheels and tires (and the little screw that comes with them)
  • 3 wooden pieces
  • 2 hook and loop squares
  • 1 mini screwdriver

Step 3: Hook and Loop

Did you know that Hook and Loop fasteners, often called Velcro™, are used by NASA because it works so well to temporarily hold things in place in zero-gravity?

We are going to use Hook and Loop squares to attach the Continuous Rotation Servos to our Mars Rover.

Hook and Loop fasteners are called that because one side has softer fabric loops, and the other side has scratchier plastic hooks that grab onto those loops.

The first thing we need to do is peel apart the squares:

Attach the soft square to one side of one of the servos:

Next, set the other servo next to the one you just placed the soft square on, and make sure it is facing the opposite direction. Then stick the other soft square to it:

Step 4: The Wheels on the Rover go Round and Round...

Now, take out the wheels and tires. Pull a tire over the wheel - it might take a bit of effort:

Do that for both tires and wheels.

Then, find the side of the tire with the hole that fits onto the servo. Line the tire up and push it onto the servo's output shaft. It might push a bit hard, but it will fit on.

Do that for both servos as well.

Finally, use the screwdriver to install a screw to hold the wheel onto the servo. Do this for both servos, too:

Step 5: Build the circuit

IMPORTANT: Before you start connecting any wires, be certain your Pico is unplugged from your computer to be sure you don't damage the Pico, servos, or your computer.

Motors use a little bit more power than anything else you may have connected to your Pico so far, so we are going to make all of our connections carefully.

You will connect your servos using the long M2M jumper wires.

Start by connecting the two jumper wires shown in red in the picture below. Plug one end into the breadboard row of the 5V pin on the Pico. Then, plug the other end of each wire into the middle socket of each servo motors' 3-pin cables:

Next, connect the jumper wires shown in black in the picture above to the breadboard row connected to the Pico's GROUND pin, and plug the other ends of the jumper wires into the socket of the servo motors' 3-pin cables that lines up with each connector's brown wire.

Place the two resistors in the breadboard like it shows in the picture above. Then, use the two shorter jumpers to connect one of the resistors to GP0 and the other resistor to GP1 on the Pico. Now, connect one of the long jumper wires to the other lead of the resistor connected to GP0 (one of the jumpers shown in yellow in the picture above). Plug the other end of the jumper wire into the last socket on one of the servo's cables. Connect the other long jumper wire from the other lead of the resistor connected to GP1 to the other servo's cable.

When your wiring is finished, click NEXT.

Step 6: Centering the servos

Before you attach your servos to the wood pieces to make the rover, we need to center the servos. This means that we are going to send the servos a "speed = zero" command that makes the servo stop moving.

To do this, grab a start block from the Chip menu and drag it into the workspace.

Grab a servo pin set speed block from the Actions menu and attach it to the start block. Then, grab a repeat forever block and attach it after the servo pin set speed block.

We aren't going to add anything in the repeat forever block, but we need it to make sure the Pico doesn't stop running our program.

Once you've built the program above, plug in your Pico to your computer's USB port, click CONNECT and select your Pico.

This next part is really important. Make sure you know which servo is connected to pin 0, and pick it up and hold onto it. When you start your program, the wheel will probably start turning!

If you don't pick up your servo, it may try to roll right off the table!

Once you are holding your servo, click START.

The wheel attached to your servo is probably spinning, and now you need to use the small screwdriver to adjust it until it stops:

You are trying to turn the adjustment screw to the "center" spot like it shows in the picture below. This center spot is not very big, so turn the screwdriver slowly. If you accidentally turn it to the transition zone, that's okay, it will just act "jittery" - just turn it to the other side:

Once your servo has stopped, you can set it down and click STOP to stop running your program.

Now, change the servo pin set speed block to pin 1.
You are going to repeat this process for your other servo.

Once both of your servos are centered, click NEXT.

Step 7: Rover Construction

Ready to build the rest of the Mars Rover? Let's go!

Attach the other two squares (these are the scratchy ones) to the spot on the bottom of the largest wood piece like it shows in the picture below:

Then, attach your servos to the squares like it shows in the picture below.

First, UNPLUG your PICO from your computer.

You are going to pull the wires through your Mars Rover, so you will need to unplug them. Make sure you reconnect them correctly. If you need to go back 2 steps to see how they are connected, that's okay!

Finally, pull the wires through the hole in the middle of the wood piece. Look carefully at the picture below. The wires on the servos should be coming out toward the back of the Mars Rover.

If the wires on your servos are coming out on the front side, simply pull the servos back off, and switch them around so that the wires come out toward the back of the Mars Rover:

Step 8: Add the Tail

Flip your Mars Rover over so that the servos are underneath. Then, slide one small wood piece into the other small wood piece as it shows in the picture below so that they fit together. Finally, slide both wood pieces into the "X" on the back of the Mars Rover:

Look carefully at the picture below. We are going to need to know which servo is the right servo, which one is the left servo, and which side of the Mars Rover is the front and which side is the back:

The right servo should be connected to GP0, and the left servo should be connected to GP1. If you need to, switch the jumper wires that are connected to GP0 and GP1 on your Pico.
Once you have finished building your Mars Rover and you've double-checked your wiring, click NEXT.

Step 9: Spin me right around

Let's do a little bit of experimenting to learn how our Mars Rover moves. We can start with a simple program.

First, delete the repeat forever block by dragging it to the trash can at the bottom of the workspace. Then, right-click the servo pin set speed block and select Duplicate. Place the new block right below the original block, and change it's pin to pin 1.

Set the speeds in both servo pin set speed blocks to 30. Finally, grab a wait block from the Chip menu and place it at the end of your program. Change the wait time to 2 seconds.

Before you plug in your Pico, connect it, and run your program make sure that you have enough room to let your Mars Rover roll around where it won't roll off your counter, desk, or table!

Plug your Pico into your computer. Click CONNECT, and then click START.

What happened? Why did the Mars Rover spin around?

Click NEXT.

Step 10: Make it Drive

Why did your Mars Rover just spin around? We set both servos to the same speed, but if you look carefully, one of them is facing the opposite direction. This means that if we want our rover to go forward, we need to spin one servo in one direction and spin the other servo in the other direction.

Change the value in the servo pin 0 set speed block to -30:

Go ahead and click START to test it out. Did it drive forward this time?

If everything worked correctly, your Mars Rover should have driven forward for 2 seconds. Unfortunately, there are usually going to be a few issues.

The first problem is that your Mars Rover might have veered a little bit to the left or a little bit to the right instead of going straight forward. Did that happen with your Mars Rover?

If you want to try and make your Mars Rover drive straighter, all you need to do is make some small adjustments to the values in the servo pin set speed blocks.

No two servos are exactly the same - so even if you send them the same signal, they probably won't go exactly the same speed. These small differences between the wheel speeds will cause the rover to veer off a straight path.

If your Mars Rover veered to the left, you can try making the left wheel (the one connected to pin 1 a little faster by changing the servo pin 1 set speed block to 31 or 32 or 33.

If it veered to the right, try setting the servo pin 0 set speed block to -31 or -32 or -33.

Experiment a little bit until you're happy with your Mars Rover's forward motion (it doesn't have to be perfect!), and then click NEXT.

Step 11: Building Functions

Let's turn forward and backward motion into functions. That way, we can re-use them over and over again in our code!

First, delete the wait 2 seconds block by dragging it to the trash can.

Grab a to do something block from the Functions menu and drag it out to the workspace. Change the name of the block to "go forward". Then, drag the two servo pin set speed blocks away from the start block and place them in the to go forward block:

Right-click the to go forward block and select Duplicate. Change the name of the new block to "go backward".

Now, switch the values so that the servo pin 0 set speed block's value is 30 and the servo pin 1 set speed block's value is -30 (or whatever values your blocks had after you adjusted them):

Step 12: Two steps forward...

Now that we have some functions, let's try making our Mars Rover move!

For our first test, let's make our Mars Rover wait 2 seconds, then go forward for 2 seconds, and then backward for 2 seconds. Grab a wait block from the Chip menu and connect it to the start block. Change wait time to 2 seconds.

Next, grab a go forward block from the Functions menu and connect it to the wait block. Right-click the wait block and select Duplicate. Connect the new block after the go forward block. Do this again with a go backward block and another wait block:

Click START to try it out.

Now your Mars Rover can do some basic movements!

We need another movement function - a stop moving function!

Right-click the go backward block and select Duplicate. Name the new block "stop moving". Change both servo pin set speed blocks to 0:

Step 13: Do I Turn Right or Left?

Now that we have forward, backward, and stop movements, let's add turns!

Remember when we first tried the Mars Rover out and it spun around? We can make the Mars Rover turn by setting the speed for both servos to the same value.

To turn left, we need to make the right wheel drive forward, and the left wheel drive backward. That means that to be able to turn left both values need to be -30.

Let's make a turn left function. Right-click the to go forward block and select Duplicate. Name the new block "turn left". Change the servo pin 1 set speed block to -30:

Let's add a left turn to the end of our program. Grab a turn left block from the Functions menu and connect it to the last wait block. Right click one of the wait blocks and select Duplicate. Connect the new block to the end of the program and change the time to 0.5 seconds:

Why 0.5? To make a turn, your Mars Rover won't have to spin it's motors for very long, so we are going to start with a really short time like 0.5 seconds.

Try it out by clicking START.

Your Mars Rover probably turned a lot - and it probably spent more than 0.5 seconds turning. The more time your rover spends turning, the more it will turn, so we actually need to use a stop moving block at the end of your program from now on.

Grab a stop moving block from the Functions menu and connect it at the end of your program. Then click START to try it again:

Did it turn straight to the left? Did it turn too much? If so, try an even smaller time like 0.45 or 0.40. If your rover didn't turn enough, try a little longer time like 0.55 or 0.60.

Experiment and tune your Mars Rover's left turn!

When you are ready, click NEXT.

Step 14: Now, go Right

A right turn is just like a left turn, except the motors need to go in the opposite direction.

Right-click the turn left block and select Duplicate. Name the new block "turn right". Change both servo pin set speed blocks to 30:

Let's add a right turn to the end of our program.

Grab a turn right block from the Functions menu and connect it right before the stop moving block. Right-click the last wait block and select Duplicate. Connect the new block right before the stop moving block:

Click START to try it out! Make adjustments to the new wait if you need to just like you did for the left turn.

Now that we have functions for each of the ways that our Mars Rover can move, let's get ready to build a program that moves our Mars Rover in a pattern.

We are about to delete some blocks, but before we do, it is a good idea to write down the wait times you used for the right and left turns.

Once you've written those times down, grab the first wait block below the start block and drag it (and all of the blocks below it) to the trash can to delete them:

Step 15: Making a List

Did you know that it takes between 3 and 22 minutes for a message from Earth to reach Mars?

If NASA wants to tell one of the Mars Rovers to move to a new position on Mars, they have to plan the Rover's trip ahead of time, and then send it the directions, because they can't see the rover driving "live". Even if the rover has a camera on it, it would take at least 3 minutes for the images and video from the camera to make it back to Earth.

Since we want the Mars Rover to move using a set of directions, we can use a list. By using a list, we can make our set of directions as long as we want.

We are actually going to need two different lists. The first list will hold the movements, and the second list will hold the wait times.

First, we need to create variables to hold each list. Click the Variables menu and then click Create variable... button. Name the new variable "movements". Drag the set movements to block out and connect it below the start block.

Next, click the Variables menu again and then click Create variable... button. Name the new variable "wait times". Drag the set wait times to block out and connect it below the set movements to block:

Grab a create list with block from the Lists menu and place it in the input of the set movements to block.

Click the blue gear icon on the create list with block. In the mini workspace, drag an item block into the list block. Do this again so that there are a total of 5 item blocks. Then, click the blue gear icon again to close the mini-workspace.

Right click the create list with block and select Duplicate. Move the new block into the input of the set wait times to block:

Step 16: Adding Movements

Now that we have our lists, let's add things to them. Grab a "_" block from the Values menu and place it into the first input of the first create list with block. Do this 4 more times to fill the list.

We are going to type 1 letter into each of the "_" blocks. Since we have 5 different movements (Forward, Backward, Left, Right, Stop), we will use the first letter to represent each one. Type 1 letter: F, B, L, R, or S into each of the "_" blocks:

Next, we need to add the wait times for each movement. Grab a 0 block from the Values menu and place it into the first input of the second create list with block. Do this 4 more times to fill the list.

Now we need to change the 0's to wait times. For forward, backward, and stop, use 2, and for turns, use 0.5 (or whatever adjusted number you came up with when you improved your turn movements):

Step 17: Repeat Until We're Done

Next, we need to loop through the list and do one of the movements based on that value in the list.

One of the cool things you can do with a list is get and remove an item in the list - so we can keep doing that to get the next movement, and stop when the list is empty!

Grab a repeat while block from the Loops menu and connect it below the set wait times block. Change the while to until. Then, grab a _ is empty block from the Lists menu and place it in the input of the repeat until block:

Grab the movements block from the Variables menu and place it into the _ is empty block. Then, grab an if _ = _ do block from the Logic menu and place it in the repeat until block. Grab an in list _ get # block from the Lists menu and place it into the left side of the _ = _ block. Change the # to first:

Since we are trying to get the first item in the movements list, grab a movements block from the Variables menu and place it into the first input of the in list _ get block.

Next, find the "F" block at the beginning of your program. Right-click and Duplicate it, and place the new block into the right side of the _ = _ block. Then, grab a go forward block from the Functions menu and place it into the if do block:

Now we have a way to take an item from the list and turn it into a movement!

Right-click the if do block and Duplicate it. Connect the new if do block right after the first if do block. Change the F in the "_" block to a B, and then delete the go forward block and replace it with a go backward block from the Functions menu:

Do this again for turn right (R), turn left (L), and stop moving (S):

Step 18: Finish the Code

Now that we are done with the first item in the movement, we need to remove it.

Right-click the last in list movements block and Duplicate it. The new block is greyed-out, but you can still change the values in the dropdown menus on the block.

Change get to remove. This will change the shape of the block. Now, connect it right after the last if do block:

Now that all of the movements are taken care of, we need to add code to wait.

Grab a wait block from the Chip menu and connect it after the in list movements remove block. Grab the 1 block inside of the wait block and drag it to the trash can to delete it.

Next, right-click one of the in list movements blocks inside of one of the if blocks and Duplicate it. Place the new block inside of the wait block. Change movements to wait times, and change get to get and remove:

Almost there! Remember that at the end of our program, we need to add a stop moving block. Grab a stop moving block from the Functions menu and place it at the end of your program:

Step 19: Try it out!

Click START to try out your program!

Did it work?
Now, for some new challenges! Try to see if you can do these with your Mars Rover:

  • Drive in a square
  • Drive in a triangle
  • Drive in a circle
  • Still have your controller? Can you write a new program to control your Mars Rover with your controller?



Give these challenges a try!

Click NEXT.

Step 20: You've Finished!

Click EXIT to return to the menu and start your next coding challenge.