Saturday, December 12, 2009

Many Ways to Program Switches

;simplest way, one switch
to go
waituntil [switcha = 1]
motor commands
waituntil [switcha = 1]
more motor commands
end

;another way, one switch
to go
if switcha = 1
[motor commands]
if switcha = 0
[more motor commands]
end

;another way, one switch
to go
ifelse switcha = 1
[motor commands]
[more motor commands]
end

;two switches!
to go
if switcha = 1
[motor commands]
if switchb = 1
[more motor commands]
end

No comments: