View unanswered posts | View active topics It is currently Mon Nov 24, 2014 8:27 am






Reply to topic  [ 1 post ] 
VEX IQ Examples: Wait for Bumper Switch 
Author Message
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 613
Post VEX IQ Examples: Wait for Bumper Switch
To help folks get up and running with the VEX IQ, we're posting a series of VEX IQ videos and sample programs that are included with ROBOTC.

This program will run your VEX IQ Clawbot forward until the VEX IQ Bump Sensor attached to Port #9 is triggered.

You can find this sample program inside of ROBOTC: Look under the "File Menu" and then "Open Sample Programs" inside of the ROBOTC interface.



Code:
#pragma config(Sensor, port9,  bumpSwitch,     sensorVexIQ_Touch)
#pragma config(Motor,  motor1,          leftMotor,     tmotorVexIQ, openLoop, encoder)
#pragma config(Motor,  motor6,          rightMotor,    tmotorVexIQ, openLoop, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   while(getBumperValue(bumpSwitch) == 0)   // Loop while robot's bumper/touch sensor isn't pressed in
   {
      setMotorSpeed(leftMotor, 63);      //Set the leftMotor (motor1) to half power (63)
      setMotorSpeed(rightMotor, 63);  //Set the rightMotor (motor6) to half power (63)
   }
   //Once the sensor is touched, the program will end and motors will stop.
}

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Sep 06, 2013 11:39 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.