|
Hey all,
I know I must be doing something very simple wrong here - but I can't for
the life of me figure it out. What I'm trying to do: Have a light sensor
pointed at a surface. Pass that value off to a variable (the variable then
contains the "ambient" light level), and then watch when the light sensor
drops about 5 counts below that (when it sees black).
Simplified, here's my code:
int threshold;
task main()
{
SetSensorType(SENSOR_1, SENSOR_TYPE_LIGHT);
OnFwd(OUT_A);
threshold=SENSOR_1;
until(SENSOR_1<threshold-5);
Off(OUT_A);
}
For some reason.. this does nothing, the motor port just stays on. I have
run into this countless times, and I can't figure out what I'm doing wrong!
Any suggestions?
Iain
|
|
Message has 2 Replies: ![](/news/x.gif) | | Re: NQC problem...driving me insane!
|
| (...) Well, actually, that code works fine (running MacNQC, a fairly recent version, with 2.0 firmware). One thing to check, code-wise, is to display SENSOR_1 on the LCD, and see what the numbers are (is it set to raw mode? Is the sensor bad (I've (...) (20 years ago, 4-Jul-04, to lugnet.robotics.rcx.nqc, lugnet.org.ca.rtltoronto)
|
3 Messages in This Thread: ![You are here](/news/here.gif) ![](/news/246.gif) ![Re: NQC problem...driving me insane! -Brian Davis (4-Jul-04 to lugnet.robotics.rcx.nqc, lugnet.org.ca.rtltoronto)](/news/x.gif)
![](/news/x.gif) ![](/news/68.gif) ![Re: NQC problem...driving me insane! -Steve Hassenplug (5-Jul-04 to lugnet.robotics.rcx.nqc, lugnet.org.ca.rtltoronto)](/news/x.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|