ROBOTC.net forums
http://robotc.net/forums/

will this work for a vex bumper
http://robotc.net/forums/viewtopic.php?f=11&t=4500
Page 1 of 1

Author:  themigthy [ Sat May 05, 2012 12:08 pm ]
Post subject:  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;
    }
  }
  }

Author:  magicode [ Sat May 05, 2012 12:19 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/