I am wanting to use the joystick control for two NXT motors. I currently have them set up so they run speed on Y1 and directon on Y2; but the speed is too quick. I used the sample joystick tank drive program and modified it. I don't understand the logic behind...so I am just not getting it to work like I want it too. I tried making the motors just run at 25% speed, but then they didn't have joystick control anymore and were always on.
Here is my current code for that function:
//trying to use tank drive to work claw
nClawPower = joystick.joy2_y1; nClawDirection = joystick.joy2_y2; if (nClawDirection < 0) { // Turn claw open
motor[TopClaw] = nClawPower; // use power settings from Y-axis motor[BotClaw] = nClawPower * (64 + nClawDirection) / 64; } else { // Turn claw shut
motor[TopClaw] = nClawPower; // use power settings from Y-axis motor[BotClaw] = nClawPower * (64 - nClawDirection) / 64;
Any suggestions would be greatly appreciated!
Tue Jan 26, 2010 4:57 pm
Jon_T
Rookie
Joined: Fri Oct 09, 2009 9:21 am Posts: 28
Re: NXT motor speed on Joystick
Take the joystick value and multiply it by a fraction such as *33/100. That way is is stll variable but slower.
_________________ Jon Thompson Coach - Twisted Bots VRC 177
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