Subject:
|
Re: FindLight
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sun, 25 Feb 2007 17:29:18 GMT
|
Viewed:
|
3699 times
|
| |
| |
Please try some semicolons on your lines!
Chris
linmix wrote:
> 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 light was seen. I don't think there is anything
> fundamentally wrong with this approach (any suggestions are welcome),
> but I've run into an error and don't know what causes it.
>
> Can anyone please explain what I'm doing wrong here?
> Thanks in advance
> linmix
>
> This is my code:
//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);
while (Timer (0) < turntime)
{
OnFwd (A);
OnRev (C);
if (SENSOR_2 > maxlight)
{
maxlight = light; // set maxlight to new max value
time = Timer(0); // remember when maxlight was found
}
}
OnRev (A);
OnFwd (C);
Wait (turntime - time); // return to the point where the highest
light level was found
}
|
|
Message is in Reply To:
| | FindLight
|
| 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)
|
10 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|