Wednesday, November 21, 2007

One reflector and the if command

Look here for the reason for these Logo posts.

Setup: Connect a motor to port A. Connect a reflector to port 1. The reflector is the blue piece with a wire attached to it.

To activate the reflector, type this in the command center and hit enter:
display reflect1
If the reflector lights up, it's ready to go.

A reflector is like a switch. If it sees a light color, it's on. If it sees a dark color, it's off. Download this program and run it. To test it out, put a white piece of paper or a white Lego in front of the red light.
to start
loop [spin]
end

to spin
if reflect1
[aoff]
if not reflect1
[aon]
end

No comments :