HP - Touch

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

ROBOTC

Reference

Touch Sensors Overview


There are two different VEX sensors, the Bumper Sensor and the Limit Switch, that act as touch sensors.
Despite their differences in appearance and usage, both sensors operate in a similar matter, and can
be programmed in the same way.

Bumper Switch Limit Switch


The Bumper Swtich, above, is a type of touch sensor for The Limit Switch is another form of touch sensor for VEX.
the VEX. Due to its size and construction, it is better suited It is more suited for detecting smaller motions that might
for tasks such as wall detection. not trigger the bumper sensor.

Both then Bumper Switch and the Limit Switch


are digital sensors. Whenever the sensor
is pressed in, it will return a value of 1.
Whenever it is not pressed in, it will return a
value of 0.

Touch sensors are used to perform a variety


of tasks, from solving a maze using wall
detection to controlling the movements of your
robot’s arm attachment.

Example of a Bumper Switch attachment

Note: On both the Bumper Switch and the Limit Switch, the red wire is not used. Even if you notice that
the red wire is “falling out” of the sensor, it should not have any effect on the sensor’s performance.

© Carnegie Mellon Robotics Academy / For use with VEX robotics systems Touch Sensors • 1
ROBOTC

Reference

Touch Sensors Natural Language Sample Code


Move Forward Until Touch
This code has the robot move forward until the sensor is pressed and then stop moving.

task main ()
{
robotType(recbot); //Specifies the robot type

forward(63); // Move forward at speed 63.


untilTouch(dgtl6); // Wait for touch sensor in digital port
// 6 to be pressed.
stop(); // Stop.
}

Move Forward When Released


This code has the robot wait until the touch sensor is released and then then move forward for 1 second.

task main ()
{
robotType(recbot); //Specifies the robot type

// Be sure to hold the touch sensor pressed in while starting


// your program!!

untilRelease(dgtl6); // Wait for touch sensor in digital


//port 6 to be released.
forward(63); // Move forward at speed 63.
wait(1.0); // Wait 1.0 second.
stop(); // Stop.
}

Bump to Spin
This code has the robot wait until the touch sensor is bumped and then spin right for 1.5 seconds.

task main ()
{
robotType(recbot); //Specifies the robot type

while(true)
{
stop(); // Stop. Do not move.
untilBump(dgtl6); // Wait for touch sensor in digital
//port 6 to be bumped.
pointTurn(right, 95); // Make a right turn in place at
//speed 95.
wait(1.5); // Wait for 1.5 seconds.
}
}
© Carnegie Mellon Robotics Academy / For use with VEX robotics systems Touch Sensors • 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy