CLICK HERE FOR INDEX PAGE

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 SENSOR - When the sensor is covered the ‘dark’ level increases from 0 to a number greater than 40. When this happens the computer looks for a second procedure called ‘Motors’.

If the sensor is not covered, the program line, ‘IF SENSOR A IS GREATER THAN 40 THEN MOTORS’, is repeated ‘forever’ until it is covered.
NOTE:
If you reverse the wires connected to the dark sensor it becomes a light sensor. Light/dark and temperature sensors are easy to make and require only simple components.

   

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.
The speed of a motor can also be altered by using the POWER command; for example, FORWARD A POWER 3. The motor keeps its strength (torque) but at a reduced speed. The power/speed is a number between 0 and 10.

If the motors need to be reversed the BACKWARD command can be used.

   
   

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.

   

 

   

CLICK HERE FOR COMPUTER CONTROL INDEX PAGE

   
 
Google
 
Web www.technologystudent.com