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