View unanswered posts | View active topics It is currently Tue Sep 30, 2014 7:11 am






Reply to topic  [ 1 post ] 
VEX IQ Examples: Line Tracking with Touch LED Indicator 
Author Message
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 604
Post VEX IQ Examples: Line Tracking with Touch LED Indicator
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 sample program will perform line tracking using the VEX IQ Clawbot with the VEX IQ Color Sensor. While the robot is line tracking, the VEX IQ Touch LED will be flashing between Red and Green, depending if the robot sees "Dark" or "Light".

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, port5,  lineDetector,   sensorVexIQ_ColorGrayscale)
#pragma config(Sensor, port12, touchLED,       sensorVexIQ_ColorGrayscale)
#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()
{
   int threshold = 790;      /* found by taking a reading on both DARK and LIGHT    */
                                          /* surfaces, adding them together, then dividing by 2. */

   clearTimer(T1);                  // Resets timer T1 to start counting at 0

   while(time1[T1] < 14000)  // Loops code while timer T1 has counted less than 10 seconds
   {
      if(getColorValue(lineDetector) < threshold)
      {
         setMotorSpeed(leftMotor, 63);      //Set the leftMotor (motor1) to half power (63)
         setMotorSpeed(rightMotor, 0);   //Set the rightMotor (motor6) to off (0)
         setTouchLEDColor(touchLED, colorRed);
      }
      else
      {
         setMotorSpeed(leftMotor, 0);      //Set the leftMotor (motor1) to off (0)
         setMotorSpeed(rightMotor, 63);  //Set the rightMotor (motor6) to half power (63)
         setTouchLEDColor(touchLED, colorGreen);
      }
   }
}

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


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

Who is online

Users browsing this forum: No registered users and 1 guest


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.