Color Bumper
The Touch LED Sensor is also considered a touch sensor, but can use to identify which part of the program is running by lighting up different colors.
Add two setTouchLEDColor command blocks to the program, one before and one right after the waitUntil command block.
The Touch LED starts red, then changes to green when the bumper switch is pressed. |
Already Pressed
What happens if you’re already pressing in the Bumper Switch when you start running the program? Try it!
The robot doesn’t move at all. The waitUntil block detects that the sensor is “Pressed” and the motors are stopped before you can observe then moving. "Pressed” simply means “the button is in the pressed position”; it does not matter how or when it was pressed in! |
Forward Until Release
Set the compare-to value on the waitUntil command to 0, and place a box against the sensor by. Try it!
The waitUntil control block can wait for the sensor to be “Released” as well as “Pressed”. The robot moves forward until the Touch Sensor is “Released”, then stops. |
Mini Challenge 1: Vacuum
Program the robot to touch all four walls of a room, using its Bumper Switch to know when it has touched each one.Start with the robot's arm in the 'up' position to expose the bumper switch.
The robot can also back away from a wall to avoid getting stuck.
Adjacent walls are just a 90-degree turn away from each other.
Did you know?
How Bumper Sensor Works
When the Touch Sensor is pressed,
it closes an electrical circuit, allowing current to flow. If the Bumper Switch is released, the circuit is broken and no current flows. The flow (or lack) of current is detected by the VEX IQ, allowing it to determine the Bumper Switch is pressed. |
|
|
Did you know?
Boolean Logic: Truth Values
Robots need to know, very clearly, which choice to make under what circumstances.
As a consequence, their decisions are always based on the answers
to questions which have only two possible answers:
yes or no,
true or false.
Statements that can be only true or false are called Boolean statements, and their true-or-false value is called a truth value. Here are some examples of Boolean Statements Robots can answer! |
|
Boolean Statement 1: The sky is blue. |
|
Boolean Statement 2: It snows during summer. |
|
Loops and If-Else conditional statements in ROBOTC are always
Boolean statements!
They are always either true or false at any given moment. |
|
Robot C Boolean Statement 1:
(NOT less than 200). |
|
Robot C Boolean Statement 2:
(less than 200). |
Did you know?
Boolean Logic: Comparison Operators
Comparisons (such as the comparison of the Ultrasonic sensor’s value against the number 200) are at the core of the decision-making process. |
ROBOTC Symbol | Meaning | Sample comparison | Result |
---|---|---|---|
"is equal to" | 50 == 50 | ||
50 == 100 | |||
100 == 50 | |||
"is not equal to" | 50 != 50 | ||
50 != 100 | |||
100 != 50 | |||
"is less than" | 50 < 50 | ||
50 < 100 | |||
100 < 50 | |||
"is less than or equal to" | 50 <= 50 | ||
50 <= 100 | |||
100 <= 50 | |||
"is greater than" | 50 > 50 | ||
50 > 100 | |||
100 > 50 | |||
"is greater than or equal to" | 50 >= 50 | ||
50 >= 100 | |||
100 >= 50 |