View unanswered posts | View active topics It is currently Mon Jul 28, 2014 10:35 pm






Reply to topic  [ 5 posts ] 
Turning on the Light Sensor 
Author Message
Rookie

Joined: Sat Feb 15, 2014 8:55 pm
Posts: 3
Post 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!


Sat Feb 15, 2014 9:01 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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?


Sun Feb 16, 2014 4:07 am
Profile
Rookie

Joined: Sat Feb 15, 2014 8:55 pm
Posts: 3
Post 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.


Sun Feb 16, 2014 12:05 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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.
    //
}


Sun Feb 16, 2014 4:29 pm
Profile
Rookie

Joined: Sat Feb 15, 2014 8:55 pm
Posts: 3
Post 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.


Sun Feb 16, 2014 4:56 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.