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

Turning on the Light Sensor
http://robotc.net/forums/viewtopic.php?f=41&t=7958
Page 1 of 1

Author:  paulelathrop [ Sat Feb 15, 2014 9:01 pm ]
Post subject:  Turning on the Light Sensor

My FTC team is trying to program a light sensor to illuminate with 40 seconds left in our two minute match.

We've determined that the "wait" value for this to happen would be "wait(80);".

Can anyone help us as far as having the led of the light sensor off until that wait time has elapsed?

Thanks!

Author:  MHTS [ Sun Feb 16, 2014 4:07 am ]
Post subject:  Re: Turning on the Light Sensor

Don't really understand your scenario. Are you saying you want to lit up the light sensor LED when there are 40 seconds left during the TeleOp period? What is this Wait(80)? There is no "Wait" function in RobotC. There is a wait1Msec or wait10Msec, but there is no "Wait". What is the unit of 80? Why would Wait(80) equivalent to 40 seconds? Any kind of wait statements would pretty much disable your robot for the wait period. Do you really mean to do that?

Author:  paulelathrop [ Sun Feb 16, 2014 12:05 pm ]
Post subject:  Re: Turning on the Light Sensor

While the robot is driving/moving we would want the wait10ms function to use a value equivalent of 80seconds (matches are 120seconds so 40 seconds left would be after 80 seconds).

After that time we would want the sensor to light up.

Author:  MHTS [ Sun Feb 16, 2014 4:29 pm ]
Post subject:  Re: Turning on the Light Sensor

Like I said, wait1Msec is not a good idea because it will make your robot sleep for 80 seconds and you will not be able to do anything else. So in your teleop robot loop, you could do something like the following.
Code:
// Turn the light sensor LED off here.
ClearTimer(T1);
while (true)
{
    if (timer1[T1] >= 80000)
    {
        // Turn the light sensor LED on here.
    }
    //
    // Do other stuff in TeleOp.
    //
}

Author:  paulelathrop [ Sun Feb 16, 2014 4:56 pm ]
Post subject:  Re: Turning on the Light Sensor

Awesome thanks for the tips. That makes alot of sense and helps us understand why earlier autonomous code had the wrong results from our expectations.

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