So far, our robots haven't been able to tell what's going on around them. Maybe your Milo or Racecar bumped into a wall?
Robots use sensors
Click here for instructions to build Milo with an addition!
Now program Milo like this.
The first, hourglass block tells Milo to wait. Use the yellow hourglass block, not the green one which is for the motor.
Until what? The orange block under the hourglass tells Milo: wait UNTIL the tilt sensor is tilted.
Then Milo goes to the next blocks, which are to move forward at power = 6 for 4 seconds.
Did you ever play Limbo? That's a game where you try to sneak under a stick two people are holding out.
Milo is going to play the opposite, Obmil, where he tries NOT to sneak under something.
Let's move Milo's head (ouch!) and put it on the tilt detector, so it's tall like a giraffe.
Make it tall enough so that when Milo goes under something like your couch or bed, it will tip the sensor back. (Don't worry - Milo won't bruise it's head. After all, we just pulled his head off and re-attached it.)
Can you make a new program which says:
1) Go forward at speed 6 (HINT: no green hourglass block!)
2) Wait until the tilt sensor is tilted. (Milo can move while it's waiting.)
3) Then stop!
Milo should drive until his head tips back, then stop. Try to figure it out yourself. You probably won't get it on the first try. Programmers hardly ever do. It's not easy stuff!
With our first program, Milo only did things once. If the sensor was forward, he moved that way and stopped.
Now make this program. You'll recognize the pieces in the middle.
Hourglass with the Tilt Sensor: Wait until the tilt sensor is flat.
Color block: Show color 9, red
Text block: Show text "Me".
Hourglass: Wait again until the Tilt Sensor is tilted back (wire pointing up).
Color block: Show color 0,
Text block: Show text "Milo" on the computer.
Go back to the first hourglass and do it all again
What do you think that yellow bar that reaches over them all with a symbol like the recycling sign does?
It's called a loop. It tells the robot to do the blocks under it all over again! ... and again. ... and again.
Try changing the blocks inside the loop. Maybe you can make Milo boogie forward and backward and play some music while it does so.
In case you had to peek, this is the solution for Obmil.