1. VEX Robotics I Power Points
Topic 09
Programming Design Basics
Bumper Switch Sensing 3
www.pedagogics.ca
2. Program sketch 3 – have your robot run through
the subroutine and stop after it makes 5
START contacts with the wall
What needs to change?
IF
TRUE Switch TRUE
WHILE DRIVE
FALSE not
t < 60 s
pressed FORWARD
?
STOP MOTORS FALSE
Stop, reverse, 180
END degree turn
3. Program sketch 3 – have your robot run through
the subroutine and stop after it makes 5
START contacts with the wall
IF
WHILE TRUE
sensor
TRUE Switch
DRIVE
FALSE not
count
pressed FORWARD
<5
?
STOP MOTORS FALSE
Stop, reverse, 180
END degree turn
5. WHILE loops can
run for a certain
Using Variables
number of cycles
by using
Any term (except for reserved words) can
variables
be used as a variable in ROBOTC
An integer variable is used to keep track of a number of events etc.
Each time the bumper is activated, we want the counter to increase by 1
6. Program sketch 3 – have your robot run through
the subroutine and stop after it makes 5
START contacts with the wall
What needs to change?
IF
WHILE TRUE
sensor
TRUE Switch
DRIVE
FALSE not
count
pressed FORWARD
<5
?
STOP MOTORS FALSE
Stop, reverse, 180
Counter + 1
END degree turn
7. Change your code and test your robot
Report to your teacher for your individual programming challenge