To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 26894
    FindLight —linmix
   I'm trying to write a simple program to make a roverbot-like robot seek for light. My basic idea is to use a timer ( Timer(0) ) to keep track of how long the robot has been turning and a variable (time) to remember the moment when the brightest (...) (18 years ago, 25-Feb-07, to lugnet.robotics)
   
        Re: FindLight —Chris Malton
     Please try some semicolons on your lines! Chris (...) //findlight.nqc #define A OUT_A #define C OUT_C int light, maxlight, time; int turntime = 500; //change to accomodate 1 turn task main() { SetSensor (SENSOR_2, SENSOR_LIGHT); ClearTimer (0); (...) (18 years ago, 25-Feb-07, to lugnet.robotics)
   
        Re: FindLight —John Barnes
   (...) I don't see where "light" ever gets set. JB (18 years ago, 25-Feb-07, to lugnet.robotics)
   
        Re: FindLight —linmix
   Thanks for the reply. I see I overlooked something significant there. Going over it all again I think I don't need 'light' Also, the parse errors are due to my omitting the ; at the end of each statement I've also discovered that I should put some (...) (18 years ago, 25-Feb-07, to lugnet.robotics)
   
        Re: FindLight —Ross Crawford
   (...) Looks like you're setting maxlight = SENSOR_2, then testing if (SENSOR_2 > maxlight), which will rarely (if ever) be true, because the value of SENSOR_2 is unlikely to change in such a short time. I think the first maxlight = SENSOR_2 (...) (18 years ago, 25-Feb-07, to lugnet.robotics)
   
        Re: FindLight —linmix
   Thanks. I thought setting maxlight before the 'if' statement would be enough, but moving it closer to the front (before the 'while' statement') did the trick. The bit after the while loop still gives me pain though. I've changed it a bit to be able (...) (18 years ago, 25-Feb-07, to lugnet.robotics)
   
        Re: FindLight —John Hansen
   (...) //findlight.nqc #define A OUT_A #define C OUT_C int maxlight; int light; int time = 0; #define TURNTIME 500; //change to accomodate 1 turn #define ROTATE_CLOCKWISE OnFwd(A); OnRev(C); #define ROTATE_COUNTERCLOCKWISE OnFwd(C); OnRev(A); task (...) (18 years ago, 26-Feb-07, to lugnet.robotics)
   
        Re: FindLight —John Hansen
   (...) I accidentally put a semicolon on the #define line above which is wrong. The program I posted will not compile unless the semicolon is removed. My apologies. It's what I get for posting late at night. John Hansen (18 years ago, 26-Feb-07, to lugnet.robotics)
   
        Re: FindLight —linmix
   Thank you for your well commented adaptation. I'm still experiencing the same problem even though the values for the different variables as shown by 'watch the brick' check out. The problem is in a different place. I wrongly assumed wait 'ticks' and (...) (18 years ago, 26-Feb-07, to lugnet.robotics)
   
        Re: FindLight —John Hansen
   (...) Use FastTimer instead of Timer for 10ms resolution. I should have remembered that last night. John Hansen (18 years ago, 27-Feb-07, to lugnet.robotics)
 

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR