Key Focus 5 - Avoid Obstacles - TTS InO-Bot Scratch Teachers Manual

Table of Contents

Advertisement

Key Focus 5 – Avoid obstacles
On the front of InO-Bot there is an ultrasonic range
finder. This is a sensor that reports values from 0 to
255. The values are reported in centimetres and
indicate how far an object is from the front of the
sensor. InO-Bot can be programmed to move around
and when the range finder reports an obstacle at a
given distance in front it can back up and turn.
The 'Movement Complete' block is defined to allow
movements to be completed before the next
command is issued. This block is there when the TTS
Scratch Launcher runs. If the block isn't available, it
can be recreated by dragging the same blocks
together, as shown.
The 'when q key is pressed' set of blocks is created as
an emergency stop. Pressing q will quickly stop InO-
Bot moving.
The 'when x key pressed' set of blocks is the main
program and InO-Bot is set to start moving forward.
The 'wait' command ensures this movement starts
before more commands are sent. The 'forever' loop
then contains a conditional check. If the distance
sensor reports an object less than 20cm in front, the
program makes InO-Bot reverse, turn and then start
moving forward again.
There is a sound added ('Play sound9') to indicate when an object is detected. The
additional wait ensures commands run.
Children should experiment with the commands above and spend time working out the
optimum trigger distance. Should it be more or less than 20cm? There may be some
discussion around the trigger point. Does InO-Bot react at exactly 20cm? If not, why
not? Often it will be a little less and this is due to reaction time, i.e. the sensor sends
data back to the PC, Scratch then needs to read that data and send commands to
make InO-Bot do something else. Data needs to be sent back and forth. Although this
data transmission is speedy there is still some lag. Are children able to modify their
program to address this? For example, they may put 25cm when they want InO-Bot to
stop at 20cm.

Advertisement

Table of Contents
loading

Table of Contents