Web control

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

Web control

Postby webbot » Tue Jul 31, 2012 8:21 am

Hi everyone!

I'm trying to create a applet in java to connect (by usb or bluetooth) to my nxt using a web browser... the problem is that when I try to launch (the typical code for PC remote control) it doesn't work. Is it necessary something else to run from a web browser?

Does anyone know some example of this?

Thanks!
webbot
New User
 
Posts: 6
Joined: Tue Jul 31, 2012 7:59 am

Re: Web control

Postby janvp » Thu Aug 09, 2012 3:56 pm

I think that a java applet usually runs in a sandbox. That means it doesnt have the rights to control the usb-port or bluetooth.
You could write a server-program that runs on your pc and controls the nxt. Then you could write an applet that sends commands to the server-program over http.
Good luck.
Sorry for my English, but I try to improve it :)
janvp
New User
 
Posts: 4
Joined: Wed Aug 08, 2012 7:40 pm

Re: Web control

Postby webbot » Thu Aug 09, 2012 4:47 pm

Yes, I found the way, I'm running a nxjpc server that connects both to the NXT and the applet...

Now I'm programming the code to read data from NXT. I saw an example but it's not quite good...
webbot
New User
 
Posts: 6
Joined: Tue Jul 31, 2012 7:59 am

Re: Web control

Postby janvp » Fri Aug 10, 2012 8:09 pm

There are two solutions. You could either use the pcapi or send messages between nxt and PC. If you use the pcapi no program is needed on the nxt because it sends so called direct commands to the nxt. On the nxt could run the lego firmware and it should work.
If you send messages your server program only needs to forward the commands from the applet to the nxt.
Its pretty easy to use the pcapi: You must only include the classes.jar(?) From lejos-folder/lib/pc . Then you can write for example: Motor.A.rotate(); See the code from my site: http://backsite.wordpress.com/2012/05/1 ... torms-nxt/ -in german
You should find many tutorials about bluetooth communication between nxt and pc.
Edit:
In this post is an example for the pcapi : viewtopic.php?f=5&t=3397
And here is a remote project with lejos and pc code: viewtopic.php?f=5&t=840
Good luck and feel free to ask here or in german on my site.
Sorry for my English, but I try to improve it :)
janvp
New User
 
Posts: 4
Joined: Wed Aug 08, 2012 7:40 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff