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 / 1177
1176  |  1178
Subject: 
Display the value of Scout sensors
Newsgroups: 
lugnet.robotics.rcx.nqc, lugnet.robotics.scout
Date: 
Thu, 26 Jul 2001 12:50:10 GMT
Viewed: 
4650 times
  
Scout is cheaper, but when you debug NQC program in Scout, you have no way to
watch the value of its sensors, I made a small program that can show sensors
value in a RCX LCD, you can use remote to change watching sensor, message 1 for
sensor1, message 2 for sensor2, message 3 for build-in light sensor.

Zhengrong

//DislayScoutSensors.nqc
#pragma noinit
int sensor = -1;
int input = 1;
int hibyte;
int lobyte;

task main()
{
#ifdef __SCOUT
    start WatchMessage;
#endif

    while (true) {
#ifdef __SCOUT
        if (input == 1) {
    sensor = SensorValueRaw(0);
}
else if (input == 2) {
    sensor = SensorValueRaw(1);
}
else {
    sensor = SensorValueRaw(2);
        }

if (sensor > 256) {
            hibyte = sensor / 256;
    SendMessage(hibyte);
    lobyte = sensor - 256 * hibyte;
    SendMessage(lobyte + 1);
}
else {
    SendMessage(sensor);
}

Wait(10);
#endif

#ifdef __RCX
ClearMessage();
until (Message() != 0);
hibyte = Message();

if (hibyte <= 3) {
    hibyte *= 256;
    ClearMessage();
    until (Message() != 0);
    hibyte += Message() - 1;
}

sensor = hibyte;
SetUserDisplay(sensor, 0);
#endif
    }
}

#ifdef __SCOUT
task WatchMessage()
{
    while (true) {
ClearMessage();
until (Message() != 0);
input = Message();
    }
}
#endif



1 Message 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