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 / 11454
11453  |  11455
Subject: 
Re: Light Sensors
Newsgroups: 
lugnet.robotics
Date: 
Sun, 7 May 2000 22:13:45 GMT
Original-From: 
Michael Cooper <mcooper@uvic.caSTOPSPAMMERS>
Viewed: 
968 times
  
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)

SetSensor(SENSOR_3, SENSOR_LIGHT);

SetSensorMode(SENSOR_1, SENSOR_MODE_RAW);    //   samething here
SENSOR_MODE_XXXXX is only valid as an argument to SetSensorMode

SetSensorMode(SENSOR_3, SENSOR_MODE_RAW);

SetSensorMode(SENSOR_2, SENSOR_ROTATION);

#endif

and your sensors should work properly. (I use NQC v3.1 and LegoFirmware Ver
0322)

~Mike


----- Original Message -----
From: "Grant Elliott" <Keysdezes@hotmail.com>
To: <lego-robotics@crynwr.com>
Sent: Sunday, May 07, 2000 8:05 AM
Subject: Light Sensors


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 is in Reply To:
  Light Sensors
 
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 (...) (25 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
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
10 hours ago
Custom Search

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