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 / 11453
11452  |  11454
Subject: 
Light Sensors
Newsgroups: 
lugnet.robotics
Date: 
Sun, 7 May 2000 15:05:29 GMT
Viewed: 
570 times
  
I've just started using NQC, and I seem to have developed a bit of an unusual
problem.  The little red LED's on my light sensors no longer turn on when
connected to the RCX.  They still work if I plug them into my Control Lab (The
computer linked interface box that came out years before Mindstorms.), yet I
can't get them to even turn on with the RCX.  Obviously, this has prevented me
from... doing much of anything.  Help would be appreciated.

Here's the code I'm using.  There are two light sensors mounted on the front,
and an angle sensor linked to the rack and pinion steering.  One motor
controls the drive wheels.  The other drives the steering.  Somehow, I doubt
this explains why the sensors won't turn on, but it might...


#define L_EYE SENSOR_1
#define R_EYE SENSOR_3
#define DIR SENSOR_2
#define DRIVE OUT_A
#define STEER OUT_B

int L_Norm;
int R_Norm;

task main()
{
#ifdef __RCX
SetSensor(SENSOR_1, SENSOR_TYPE_LIGHT);
SetSensor(SENSOR_3, SENSOR_TYPE_LIGHT);
SetSensor(SENSOR_1, SENSOR_MODE_RAW);
SetSensor(SENSOR_3, SENSOR_MODE_RAW);
SetSensor(SENSOR_2, SENSOR_ROTATION);
#endif
L_Norm = L_EYE;
R_Norm = R_EYE;
SetPower(STEER,3);
SetPower(DRIVE,8);
ClearSensor(DIR);
On(DRIVE);
while(true)
{
if ((L_EYE - L_Norm) > 20)
{
Rev(DRIVE);
OnFor(DRIVE,100);
Fwd(STEER);
while(DIR<5)
{
On(STEER);
}
Off(STEER);
Fwd(DRIVE);
OnFor(DRIVE,200);
Rev(STEER);
while(DIR!=0)
{
On(STEER);
}
On(DRIVE);
}
if ((R_EYE - R_Norm) > 20)
{
Rev(DRIVE);
OnFor(DRIVE,100);
Rev(STEER);
while(DIR > (0 - 5))
{
On(STEER);
}
Off(STEER);
Fwd(DRIVE);
OnFor(DRIVE,200);
Fwd(STEER);
while(DIR!=0)
{
On(STEER);
}
On(DRIVE);
}
}
}



Message has 1 Reply:
  Re: Light Sensors
 
Hey Grant, I found a few problems in your code. Change the #ifdef block to be #ifdef __RCX SetSensor(SENSOR_1, SENSOR_LIGHT); // SENSOR_TYPE_LIGHT isnt a valid type for SetSensor you need to USE SENSOR_LIGHT ( check the NQC documentation for types) (...) (24 years ago, 7-May-00, to lugnet.robotics)

2 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