To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1686
1685  |  1687
Subject: 
NQC problem...driving me insane!
Newsgroups: 
lugnet.robotics.rcx.nqc, lugnet.org.ca.rtltoronto
Date: 
Sun, 4 Jul 2004 14:58:42 GMT
Viewed: 
5490 times
  
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:
  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)
  Re: NQC problem...driving me insane!
 
(...) You should check to make sure your light sensor is in fact changing more than 5 counts. Start by changing the above code to 2 or 3. I don't recall with NQC, but with some languages (BrickOS) the values are backwards, so you may need to check (...) (20 years ago, 5-Jul-04, to lugnet.robotics.rcx.nqc, lugnet.org.ca.rtltoronto)

3 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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