Sensor Events not working when using CONTROLLED_MOTORCMD

View previous topic View next topic Go down

Sensor Events not working when using CONTROLLED_MOTORCMD

Post  Joachim_374 on Thu Feb 23, 2012 7:20 pm

Hi,

I have the following problem:
When I am using the MotorControlProxy MotorControl the Events for the sensors are not working anymore Neutral

This is my code (vb.net)

Code:

        ' Create a NXT brick, USB connected
        Dim Brick As NxtBrick = New NxtBrick(NxtCommLinkType.USB, 0)

        ' Attach a motor to port A.
        Brick.MotorA = New NxtMotor()

        ' Attach a touch sensor to port 3.
        Brick.Sensor3 = New NxtTouchSensor()
        Brick.Sensor3.PollInterval = 50


        Dim touchSensor As NxtTouchSensor = DirectCast(Brick.Sensor3, NxtTouchSensor)
        touchSensor.PollInterval = 50

        ' Connect to the NXT.
        Brick.Connect()

        ' Start the MotorControl program on the NXT and wait intill it is running.
        MotorControlProxy.StartMotorControl(Brick.CommLink)
        System.Threading.Thread.Sleep(500)

        'Test - run MotorA
        MotorControlProxy.CLASSIC_MOTORCMD(Brick.CommLink, MotorControlMotorPort.PortA, "010", "000000", "1")

        Do Until True = False
            touchSensor.Poll()
            Brick.Sensor3.Poll()

            If DirectCast(Brick.Sensor3, NxtTouchSensor).IsPressed = True Then Stop
            If DirectCast(touchSensor, NxtTouchSensor).IsPressed = True Then Stop
            If touchSensor.IsPressed = True Then Stop

            Application.DoEvents()
        Loop

        ' Disconnect from the NXT.
        Brick.Disconnect()

The Senosor3 do not respond. I tried to do this using Events - but this was also not working :-(

When I remove then motorControl then it works fine ;-)

Who can correct my code?

Joachim

Joachim_374

Posts : 3
Join date : 2012-02-23

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum