|
When I first bought my RCX some time ago, I dreamed of using the remote control
to drive the train. Well I think I finally have it working. The following
code works but has a problem which perhaps somebody can help me with.
The program looks for input from the message buttons on the infrared remote.
Message 1 decreases speed, Message 2 sets the speed to 0, and Message 3
increases the speeed. On problem I have is that when I give it message 2, the
variable 'speed' goes to zero but the motor doesn't stop. Anyone know what I'm
doing wrong? Anyone have suggestions for refining the code. Perhaps a better
speed control algorithem. Thanks to Dave B(for NCQ) and Mark Overmars (for the
tutorial)
Thanks for any advice, hints, feedback or suggestions
Here is the code: (please excuse me if it is not appropriate to post it here)
int speed , __speed;
task run_motor()
{
while (true)
{
__speed = speed;
if (__speed > 0) {SetPower(OUT_A,speed);OnFwd(OUT_A);}
if (__speed < 0) {SetPower(OUT_A,-speed);OnRev(OUT_A);}
}
}
task check_sensors()
{
while (true)
{
ClearMessage();
until (Message() != 0);
if (Message() == 1) {speed = speed -1;}
if (Message() == 2) {speed = 0;}
if (Message() == 3) {speed = speed +1;}
}
}
task main()
{
speed = 0;
start run_motor;
start check_sensors;
}
|
|
Message has 3 Replies:
84 Messages in This Thread: ![You are here](/news/here.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NCQ and RCX -Dan Boger (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NCQ and RCX -Ben Fleskes (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/268.gif) ![Re: infrared remote control of LEGO trains using NCQ and RCX -Reinhard "Ben" Beneke (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Ben Fleskes (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Ludo Soete (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Reinhard "Ben" Beneke (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -John Neal (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -James Powell (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Frank Filz (23-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/268.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/246.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -John Neal (23-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/268.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -James Powell (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (23-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Stacy J. Bledsoe (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Stacy J. Bledsoe (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Stacy J. Bledsoe (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (24-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Michel Magnan (24-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Stacy J. Bledsoe (26-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Jawn Henry construction notes (was Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (27-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: Jawn Henry construction notes (was Re: infrared remote control of LEGO trains using NQC and RCX -Christopher Masi (27-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: Jawn Henry construction notes (was Re: infrared remote control of LEGO trains using NQC and RCX -Stacy J. Bledsoe (27-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -John Neal (23-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Larry Pieniazek (24-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: infrared remote control of LEGO trains using NQC and RCX -Frank Filz (23-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![More Train Thoughts - was remote control -Ralph Hempel (22-Mar-00 to lugnet.trains)](/news/x.gif) ![](/news/46.gif) ![Re: More Train Thoughts - was remote control -Frank Filz (22-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![roundhouse discussion: was: Re: infrared remote control of LEGO trains using NQC and RCX -Ben Fleskes (22-Mar-00 to lugnet.trains)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![New LEGO train realism? (was:Re:infrared remote control of LEGO trains using NCQ and RCX) -John Neal (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism -John Gerlach (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? (was:Re:infrared remote control of LEGO trains using NCQ and RCX) -Reinhard "Ben" Beneke (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? (was:Re:infrared remote control of LEGO trains using NCQ and RCX) -Larry Pieniazek (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -Reinhard "Ben" Beneke (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Ben Fleskes (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![module standards -Christopher Tracey (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Larry Pieniazek (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -James J. Trobaugh (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -John Gerlach (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -James J. Trobaugh (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Christopher Masi (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Ben Fleskes (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Dean Husby (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/268.gif) ![Re: New LEGO train realism? -Ben Fleskes (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Mike Walsh (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![Club Table Standards was Re: New LEGO train realism? -James J. Trobaugh (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: Club Table Standards was Re: New LEGO train realism? -Christopher Tracey (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: Club Table Standards was Re: New LEGO train realism? -James J. Trobaugh (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: Club Table Standards was Re: New LEGO train realism? -James J. Trobaugh (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Kevin Wilson (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -John Gerlach (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Reinhard "Ben" Beneke (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -Daniel Siskind (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![GMLTC Storm Watch 2000 -John Kelly (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![Re: New LEGO train realism? -John Matthews (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -John Gerlach (22-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Mike Poindexter (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -John Gerlach (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Charles Eric McCarthy (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -Daniel Siskind (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -John Matthews (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Tom Stangl (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -John Gerlach (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Mike Poindexter (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -John Kelly (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -Mike Poindexter (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -John Gerlach (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Legomodular standards -Larry Pieniazek (23-Mar-00 to lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Mike Poindexter (23-Mar-00 to lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/246.gif) ![Re: New LEGO train realism? -John Gerlach (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -John Kelly (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif) ![](/news/46.gif) ![Re: New LEGO train realism? -Mike Poindexter (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![Re: New LEGO train realism? -Brian Williams (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Reinhard "Ben" Beneke (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: New LEGO train realism? -Larry Pieniazek (23-Mar-00 to lugnet.trains, lugnet.trains.org)](/news/x.gif)
![](/news/x.gif) ![](/news/68.gif) ![Re: infrared remote control of LEGO trains using NCQ and RCX -Dean Husby (22-Mar-00 to lugnet.robotics.rcx.nqc, lugnet.trains)](/news/x.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|