Lesson
1 Lesson
2 Lesson
3 Lesson
4 Lesson
5 Lesson
6
Note: Days 4 and 5 cover simmiler material and can be combined into a two part
class. I present them here as two days because students typically have trouble
understanding this topic if it is covered too quickly.
Topics
If/Else (Forks)
Jumps
Handouts
Forks Challenges
Jump Challenges
Lesson
Begin this lesson by explaining the general concept of an if/else (or Fork)
statement. One of the easier ways to do this is by using real life examples. If
it is sunny out put on your sunglasses else it is raining so put up an umbrella.
The if/else is a decision based on the way things are right now.
Put up an example program on the board and have the students guess what it does.
This program makes a different sound based on the touch sensor. So if the touch
sensor is released it beeps a C note twice. Else if the sensor is pushed in it
beeps an E note once. (Note: since there is no time between the go light and the
if/else, the program will check the status of the sensor the instant it starts.
So if you want it to play the E note, it is best to hold the sensor in while
hitting the Run button. )
Here is another simple program that randomly decides which direction the program
takes.
This is the exact same program from above except that it randomly decides to
play two C notes or one E note.
Divide the students into their groups and give them the Forks handout. Have the
students complete the two challenges in the handout then have a short class
discussion on it. What worked? What didn't? How could Forks be useful?
During the discussion point out how the robot only goes through the fork once.
So for the example program it only beeped the note once. Wouldn.t it be nice if
the robot could do it more than once?
Modify the program on the board to this Jump program:
Unlike forks, jumps have no modifiers, when the program hits a Jump (arrow up)
icon, it instantaniously moves the the Land (arrow down) icon of the same color.
This is useful in programs that use an if statment like:
This program will play a C note as long as the sensor is not pressed. as soon as
the sensor is pressed it will play a short song and stop.
Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6