View unanswered posts | View active topics It is currently Mon Oct 20, 2014 7:19 am






Reply to topic  [ 2 posts ] 
will this work for a vex bumper 
Author Message
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post will this work for a vex bumper
Code:
if(SensorValue(touchSensor) == 1)
  {
  int threshold;
  threshold = 1500;


  while(SensorValue(touchSensor) == 1) // if the sensor equals to one touch the program will run
  {

    if(SensorValue(lineTrakingleft) > threshold) // all the rest is basically line tracking for my autonomous program. but im not done yet.   
    {

      motor [frontLeftMotor]   = 0;
      motor [leftmiddle]          = 0;
      motor [backLeftMotor]    = 0;
      motor [backRightMotor]   = 40;
      motor [frontRightMotor]  = 40;
      motor [rightmiddle]      = 40;
    }

    if(SensorValue(lineTrakingmiddle) > threshold)
    {
      motor [frontLeftMotor]   = 40;
      motor [leftmiddle]       = 40;
      motor [backLeftMotor]    = 40;
      motor [backRightMotor]   = 40;
      motor [frontRightMotor]  = 40;
      motor [rightmiddle]      = 40;
    }

    if(SensorValue(lineTrakingright) > threshold)
    {
      motor [frontLeftMotor]   = 40;
      motor [leftmiddle]       = 40;
      motor [backLeftMotor]    = 40;
      motor [backRightMotor]   = 0;
      motor [frontRightMotor]  = 0;
      motor [rightmiddle]      = 0;
    }
  }
  }


Sat May 05, 2012 12:08 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: will this work for a vex bumper
*I've done it for you here, but next time you post code, please put it in
Code:
[code][/code]
tags to make it easier to read.
Right now, the way you have it, if the bumper isn't pressed when you start the program, it will immediately end. It will check the first if statement, and if it's not pressed, go down to the end, where I see no more code. If you want it to keep checking, you're going to have to put everything in a while loop.

_________________
sudo rm -rf /


Sat May 05, 2012 12:19 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

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.