Rover Coding Challenges

NOTE: As you complete each task you need to take a photo of your code and then paste it into the appropriate section of your R&D Workbook.

Rover Task 1 - Forwards & Backwards

Write a small program that will make your Rover go forwards for 3 seconds, stop and then go backwards for 3 seconds.

Rover Task 2 - Lights & Noise

Re-save Task 1 (as Task 2) and add extra commands that get the lights to come on when going forwards and to make a noise before going backwards.

Rover Task 3 - Create Functions

Creating a function will save time and effort spent writing the same thing a number of times. Below is some code to get you started for creating a right_turn function. You need to copy the code and then test the function by running it. How many seconds does it takes for your robot to complete a 90 degree turn? Enter this in the wait block.

Your task is create a function for turning right and one for turning left.

Rover Task 4 - Obstacle Course

Write code to get your Rover to complete the Obstacle Course shown below. Try to avoid hitting any obstacles. Using a function for turning, like you created in the last task, will make your solution more efficient.

 

Rover Task 5 - Repeat Command

Use a Repeat command to make your Rover drive in a square and then stop at the same point that it started from. Try to use the least amount of blocks possible.

Rover Task 6 - Infrared Sensor

Create the following code and work out what it does. Can you explain each command?

Rover Task 7 - Stop and Turn with Repeat

Re-save Task 5 and call it Task 6. You are now going to add your own commands to the code. Your new code should:

Change the speed to fast

Flash lights and go backward for 1 sec after the Stop command

Turn 90 degrees

Play a sound and change the colour of the eyes

Repeat the whole sequence 4 times