controll motors over bluetooth

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

Moderators: 99jonathan, roger, imaqine

controll motors over bluetooth

Postby Purzel2003@web.de » Wed Mar 12, 2008 4:32 pm

Hello,
I'm new at programming java and lejos. I try to communicate between two nxt bricks over bluetooth. I have a bluetooth connection between the two devices, but I don't know how to controll the motors of the bicks. One possibility is to use the data input and output stream. But I don't know how does it works. Can someone help me with a code example.
Thanks.
Purzel2003@web.de
New User
 
Posts: 3
Joined: Wed Mar 12, 2008 4:22 pm

Re: controll motors over bluetooth

Postby bbagnall » Wed Mar 12, 2008 7:17 pm

Purzel2003@web.de wrote:Hello,
I'm new at programming java and lejos. I try to communicate between two nxt bricks over bluetooth. I have a bluetooth connection between the two devices, but I don't know how to controll the motors of the bicks. One possibility is to use the data input and output stream. But I don't know how does it works. Can someone help me with a code example.
Thanks.


Really, you are new to programming Java, new to leJOS and for your first project you are going to start your journey by programming two bricks communicating with Bluetooth. Okay, who am I to argue with that?

We have a solution for communicating using remote motors and sensors in the package lejos.nxt.remote, seen here:
http://lejos.sourceforge.net/p_technolo ... index.html

You should first look at the sample code in the samples directory called RemoteNXTTest.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby PatrickLismore » Wed Mar 12, 2008 7:17 pm

There are two example classes in the Lejos folder called Samples

Lejos_nxj > Samples >

One class will be for your master NXT and there is another class for your slave NXT

the example classes connect the NXT's and send integers back and forth

use them as a base for your programs , extend them and amend to suit your project
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague

Postby PatrickLismore » Wed Mar 12, 2008 7:26 pm

What I have been doing is

sending from one brick to the other,

integers (numbers) 1,2,3,4

so on the master brick "if" the left motor is stopped then i send a 1 and if its going i send a 2 and for the right motor i say "if" the right motor is stopped i send a 3 and if its going i send a 4.

That way on your slave robot its easy to decode the signal ,

based on the integer your sending to it,

There is also another way using the pilot.steer() class but i have not used that.
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague

Postby Purzel2003@web.de » Thu Mar 13, 2008 8:05 am

This project is a project for the university. I try to build up a jenga tower and there for I need 5 motors.
Thanks for the quick reply. I tried it to send integers when one motor finishes and start the other one and this works. This method was too simple for me.
Purzel2003@web.de
New User
 
Posts: 3
Joined: Wed Mar 12, 2008 4:22 pm


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

more stuff