View unanswered posts | View active topics It is currently Wed Sep 26, 2018 4:53 am

Reply to topic  [ 2 posts ] 
Author Message

Joined: Mon Nov 08, 2010 2:00 pm
Posts: 6

I am kind of new to programming but i'm getting the hang of it now. I have one problem that I haven't been able to solve. i have an Nxt motor. I want to be able to press a button on the joystick, and while it is pressed i want the motor to move to a certain position. Yet if i let go of the motor i want it to stop moving. If i keep pressing the button I want it to get to its limit position. Once it gets to the limit position, even if i am pressing the button, i want it to stop. The limit position is just a variable number. How can I go about doing this? I have tried to use the sample code given in Robot C for lego motors and I have tried to modify it but i just cant seem to get it to work. I would really appreciate your help. Thank You

Tue Feb 08, 2011 1:57 pm
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
I don't have RobotC in front of me, so some of the functions may be wrong, but it looks something like this:
nMotorEncoder[motorA] = 0;
while (true)
    if (joyBtn(1) && (nMotorEncoder[motorA] < target)
        motor[motorA] = 50;
        motor[motorA] = 0;

Tue Feb 08, 2011 2:50 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.