A COMPUTER PROGRAM
V. Ryan © 2002 - 04
A computer program is a list of commands. These commands control the interface which in turn is connected to a robotic device. Normally, when writing a program, a flow chart is drawn first and this sets out clearly the sequence of instructions (see previous notes). The program below controls a robotic face. The face has to eyes which are attached to motors ‘A’ and ‘B’. A dark sensor is in the centre of the nose. When the sensors is covered both eyes will rotate in a clockwise direction for four seconds and then stop. Programs are written in sections - called procedures. |
|
This program is in two parts. The first ‘procedure’
controls the dark sensor (sensor A) and the second controls the two motors.
The first procedure continually checks to see if the sensor has been covered
or not. This sensor is an ‘analogue’ sensor. |
|
The first line in the second procedure turns on motor ‘A’
at speed 3. It then turns on motor ‘B’, again at speed 3. The procedure
waits for 4 seconds and then stops motors A and B through the HALT command. |
|
Write a small program which will control the small robotic device shown above. You may wish the eyes to move in opposite directions when the light sensor is covered. Alternatively, you may want it to activate the motors when light shines on the sensor. |
|
|
|
|
|