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

Problems with coding a limit switch
http://robotc.net/forums/viewtopic.php?f=52&t=13441
Page 1 of 1

Author:  lazerblast8 [ Tue Feb 23, 2016 9:46 am ]
Post subject:  Problems with coding a limit switch

Hello I am in a high school engineering class we are using vex cortex parts and robotC for a project we are using. The problem we are having right now is that we are trying to use a limit switch to try and keep track of how many times it has been pressed down. The switch seems to count at a inconsistent rate and at this point we don't know what to do anymore. If there anything suggetions you have please let us know or if there is a better way to approch this all together that would help a lot. Thank you for your time.

Code:
 #pragma config(Sensor, dgtl1,  limitSwitch,    sensorTouch)
#pragma config(Motor,  port2,           motorOne,      tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   int w = 0;
   motor[port2] = 0;

   wait1Msec(2000);

   while (1==1)
   {
      if (SensorValue(limitSwitch) == 1)
         w = w + 1;

      if (w > 5000)
         motor[port2] = 100;
   }
}

Author:  mightor [ Wed Feb 24, 2016 3:20 am ]
Post subject:  Re: Problems with coding a limit switch

This is a similar issue to the one I explained here: viewtopic.php?p=38220#p38220

= Xander

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