programing Questions

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

programing Questions

Postby nat1 » Sun Oct 21, 2007 11:47 pm

hi

I had a Question about programing: How do you get 2 motors to rotate at the same time? btw I'm new to this. :lol:
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby roger » Mon Oct 22, 2007 6:27 am

There is an example in the Motor API, part of the lejos NXT Documentation.
Go to lejos_nxj\docs\apidocs and click on indx.html.
Good luck,
Roger
roger
Moderator
 
Posts: 360
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Postby nat1 » Mon Oct 22, 2007 10:48 pm

hi

could you tell me where in the api or even beter could you give an ex. in a program. thanks alot.
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby 99jonathan » Mon Oct 22, 2007 11:57 pm

Motor.A.forward();
Motor.C.forward();
Thread.sleep (1000);
Motor.A.stop();
Motor.C.stop();
99jonathan
Moderator
 
Posts: 122
Joined: Thu Mar 01, 2007 5:30 am

Postby nat1 » Wed Oct 24, 2007 12:43 am

hi

Thanks I got it now I wanted to know that beacuse I'm making a walking robot and I needed the hip and knee to move together. :lol:
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby nat1 » Sun Oct 28, 2007 4:54 pm

hi

somthing else is there a way to use the rotateTo comm and make two motors move to diffrent angles at once?
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby lawrie » Sun Oct 28, 2007 10:09 pm

Set immediateReturn to false.

For example:

Code: Select all
Motor.A.rotateTo(30,false);
Motor.B.rotateTo(60,false);
while(Motor.A.isRotating());
while(Motor.B.isRotating());
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Postby nat1 » Sun Oct 28, 2007 10:31 pm

hi

do I need the while(Motor.A.isRotateing()).?
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a

Postby bbagnall » Sun Oct 28, 2007 10:55 pm

The while-loop just waits until the motors are both done rotating. If you want other processing to go on while they are rotating (which I doubt you would) then you could omit those loops.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby nat1 » Mon Oct 29, 2007 12:09 am

hi

thanks a lot :lol: :lol:
Thanks!

Nat
nat1
Novice
 
Posts: 79
Joined: Mon Sep 10, 2007 1:21 am
Location: n/a


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff