Lesson 1
(Shaky Sequence)

Learning Intention
- I can program a robot to carry out a sequence of movements
Introduction
We are going to be using a robot called Ohbot. Ohbot can sense the world using input devices including a keyboard, mouse, microphone or camera connected to a computer. It can ‘think’ using a program running on the computer. It can act using motors and a speaker connected to a computer. We are going to start by creating a program to make Ohbot carry out a sequence of movements.
We are going to be using a robot called Ohbot. Ohbot can sense the world using input devices including a keyboard, mouse, microphone or camera connected to a computer. It can ‘think’ using a program running on the computer. It can act using motors and a speaker connected to a computer. We are going to start by creating a program to make Ohbot carry out a sequence of movements.

Start with a new program by selecting New from the File menu
Click on the Events button to display the Events palette and drag a when green flag clicked block on to the programming canvas.
Click on the Motion button to display the Motion palette and drag a set HeadTurn to 5 block on to the programming canvas. Join this up with the when green flag clicked block by dropping it on the bottom of that block.
When you run the program, by clicking the green flat, it will set the motor to a position that corresponds with the number in the second box, in this case 5. With all Ohbot motors, 10 is the furthest in one direction and 0 is the furthest in the other direction, 5 will always bring Ohbot back to the middle position. Set HeadTurn to 10 and click the green flag then set HeadTurn to 0 and click the green flag to see what happens. Try setting a value greater than 10 or less and 0. Try a decimal value.
Click on the Events button to display the Events palette and drag a when green flag clicked block on to the programming canvas.
Click on the Motion button to display the Motion palette and drag a set HeadTurn to 5 block on to the programming canvas. Join this up with the when green flag clicked block by dropping it on the bottom of that block.
When you run the program, by clicking the green flat, it will set the motor to a position that corresponds with the number in the second box, in this case 5. With all Ohbot motors, 10 is the furthest in one direction and 0 is the furthest in the other direction, 5 will always bring Ohbot back to the middle position. Set HeadTurn to 10 and click the green flag then set HeadTurn to 0 and click the green flag to see what happens. Try setting a value greater than 10 or less and 0. Try a decimal value.

Next, we will write a program to make Ohbot carry out a sequence of movements to make it shake its head. First, we need a when green flag clicked instruction from the Events palette to make the sequence start. Then we will need a sequence of set HeadTurn to instructions from the Motion palette. What do you think will happen with this sequence of blocks?
Computers carry out instructions almost unimaginably quickly, the three blocks will run in around 0.000000003 of a second. Even if Ohbot’s motors could move this fast –which they can’t- your eye probably wouldn’t be able to perceive the movement. One way of slowing down the movement is to add an instruction that makes the program wait between each of the instructions.
Computers carry out instructions almost unimaginably quickly, the three blocks will run in around 0.000000003 of a second. Even if Ohbot’s motors could move this fast –which they can’t- your eye probably wouldn’t be able to perceive the movement. One way of slowing down the movement is to add an instruction that makes the program wait between each of the instructions.

Wait can be found on the Control palette and will give Ohbot’s motors time to move to each position before the next position overrides it. Once the code is complete we need to click the green flag to test it. We may need to debug the code if it is not working correctly. Think about what your Ohbot is doing compared to what you want it to do. Identify the instruction or instructions that are causing this and identifying a possible solution to try before running again. Once the code is fully working, save your work using by selecting Save As from the File menu. Save as ‘head shake’ to complete the task. We can now use this first simple program we have written as a skeleton to make other parts of Ohbot move.
Activities
1. Write a program to make Ohbot nod its head up and down.
2. Write a program to make Ohbot’s eyes look from left to right.
3. Write a program to make Ohbot’s eyes look up and down.
Extension
Experiment to write a sequence to make other parts of Ohbot move?
1. Write a program to make Ohbot nod its head up and down.
2. Write a program to make Ohbot’s eyes look from left to right.
3. Write a program to make Ohbot’s eyes look up and down.
Extension
Experiment to write a sequence to make other parts of Ohbot move?