Subject:
|
Scout and External Iight sensor question
|
Newsgroups:
|
lugnet.robotics.scout
|
Date:
|
Sat, 20 Jan 2001 13:43:18 GMT
|
Viewed:
|
2216 times
|
| |
| |
Hi all,
I read once that it is possible to use an external light sensor on on of the
2 available input ports on the SCOUT in RAW mode. I attempted to do this
with SENSOR_1 in NQC with little success.
Here is what I have tried.
SetSensorType(SENSOR_1, SENSOR_LIGHT);
SetSensorMode(SENSOR_1, SENSOR_MODE_RAW);
On first try - got an error SENSOR_LIGHT variable undefined...
Then I commented out the first line and hoped that by setting SENSOR_1 to
RAW, the SCOUT could interpret the values correctly...
I built a calibrate function that would calibrate the light values and play
a sound based on the light value.
Here is part of the code:
i = 0;
runningTotal = 0;
while (i < 10)
{
runningTotal += SENSOR_1;
Wait(50); // .5 sec
i += 1;
if (c == 0) // calibrate black
{
blackthresh = runningTotal / 10;
PlayTone(blackthresh , 10
}
(note there may be { placement errors as some code has been clipped.)
When the program runs it will loop through 10 iterations, sample the light
and play a sound based on the light value. I get no sound... The variable
blackthresh is evaluating to 0. So to verify that the PlayTone is working,
I add 100 to blackthresh:
PlayTone(whitethresh + 100, 10)
This gives me a consistent sound for each of the 10 iterations of the light
calibration procedure.. What I get from this is that the SCOUT is not
reding the light sensor values in RAW.
Any suggestions / ideas would be appreciated.
Thx,
Dave
|
|
Message has 1 Reply:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|