Learning Goal: Student will be able to write a program that controls the robot
Daily objective: Student will understand that functions can simplify a program.
Sometimes when you write a program, you need to repeat commands over and over again.
If I want to write a program to make the robot move fowards, then play a tune, move backwards then play the same tune, and turn before playing the same tune again, that program will be very long.
Instead of this long, confusing program, you can write short bits called functions that program the
repeated parts and that can be called
again and again. This makes the program easier to write, and also easier to read.
Lesson 4 Video - Functions
Assignment 4 -
Open the fire rescue world on the simulation. Define a function called ‘fire’ to make the GearBot
spin on the spot, saying ‘Fire’ until it faces the way it started again. Write a program that
makes the GearBot drive around the Fire Rescue world on any path that you choose, calling the ‘fire’ function when it is near one of the fires.
Save it to a folder on your computer as functionyourname.
To turn it in, look at the instructions below or watch this video:
- Go to Google Drive
- Open the Class Program folder in 'Shared with me'
- Open your class folder and assignment folder
- Click on the "New" button on the top left
- Upload the program from your computer
Write a Reflection on what you have learned.
|