How can I program turns using degrees instead of motor duration?
Thanks,
rail33
Sat May 17, 2008 4:15 pm
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 298 Location: San Diego, California. USA
Hi rail33,
To do this you have to use the built in rotation sensor in the motor, called the encoder. Here is some sample code that shows you how to set up a motor encoder target, let me know if this helps B-).
Scott B-)
Code:
task main() { nMotorEncoder[motorA] = 0; // reset encoder to 0 position nMotorEncoderTarget[motorA]=1000; //where you want to move to motor[motorA] = 100; //move at full speed
while (nMotorRunState[motorA] != runStateIdle) //will do whats in brackets untill it gets to its target// { nxtDisplayTextLine(2,"Enc A=%d", nMotorEncoder[motorA]); //display encoder on the nxt screen// } }
Users browsing this forum: No registered users and 6 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