View unanswered posts | View active topics It is currently Fri Apr 20, 2018 12:41 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Autonomous with light sensors (robot C)
Author Message
Rookie

Joined: Fri Feb 06, 2009 11:37 pm
Posts: 1
Autonomous with light sensors (robot C)
okay, so for our autonomous, we have two light sensors following a line and stopping at the puck rack. but our problem is that the robot just keeps going. we need the robot to stop in three seconds, but wherever we put wait1msec(3000), it ignores the lightsensors. the program just keeps looping. does anyone know how to stop it??

Fri Feb 06, 2009 11:46 pm
Novice

Joined: Tue Jan 13, 2009 5:22 pm
Posts: 72
Location: USA, Pennsylvania
Re: Autonomous with light sensors (robot C)
Here is a simple program that you might have use for.

 Quote:task main(){ time1(T1) = 0; // Resets the T1 to 0 while(time1(T1) < 3000)condition // While time from T1 is less than 3000 run next { if(SensorValue(lightSensor) < 45)// Might need to be changed b/c of the difference between light sensors { motor[motorB] = 100; motor[motorC] = 0; } else { motor[motorB] = 0; motor[motorC] = 100; } }}

_________________
We need a Linux Version!

Sat Feb 07, 2009 12:17 am
Novice

Joined: Fri Oct 24, 2008 8:58 am
Posts: 87
Re: Autonomous with light sensors (robot C)
The only thing I would add is that its probably best to have a small delay every time through the loop. Other wise you're not giving the system any time to respond (and potentially not giving other tasks time to process)

 Code:task main(){ time1(T1) = 0; // Resets the T1 to 0  while(time1(T1) < 3000)condition // While time from T1 is less than 3000 run next {   /* Check your sensors here and follow the line */   wait1Msec(10);   // Wait 10 msec until we check sensors again }}

if your short on timers (since there's only 4) you could easily use a variable counter in this scenario.

 Code:task main(){  int loopCount = 0;  while(loopCount < 300) // 300 loops of 10 msec = 3000msec = 3 sec  {    /* Check your sensors here and follow the line */    wait1Msec(10);   // Wait 10 msec until we check sensors again    loopCount += 1;  }}

Sat Feb 07, 2009 11:00 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning