Using Lego Nxt mindstorm with processing
in
Integration and Hardware
•
1 year ago
Hello.
I have a problem using the NXTComm library by Jorge Cardoso.
I'm running it on Win7 computer
I plug the nxt brick via usb (HUB 1).
The birick runs with the firmware 1.28
I have an issue using the following sketch
- // NXT Sensor Value Viewer by: Diego Baca, 2007.
- // Load Libraries:
- import processing.serial.*;
- import SpringGUI.*;
- import pt.citar.diablu.nxt.protocol.*;
- import pt.citar.diablu.processing.nxt.*;
- import pt.citar.diablu.nxt.brick.*;
- SpringGUI gui;
- LegoNXT nxt;
- PImage nxtImg;
- PFont fontA;
- PFont fontB;
- void setup(){
- size(800,450);
- smooth();
- // Load background Image
- nxtImg = loadImage("nxtsvv.jpg");
- // Load Fonts
- fontA = loadFont("HelveticaNeue-12.vlw");
- fontB = loadFont("HelveticaNeue-Bold-12.vlw");
- // Start connection with LegoNXT brick
- println(Serial.list());
- nxt = new LegoNXT(this, Serial.list()[5]);
- // Create radio buttons
- gui = new SpringGUI(this);
- gui.addRadiobutton("myRBN1", "On", "motor1", 260, 30, 70, 20);
- gui.addRadiobutton("myRBN2", "Off", "motor1", 260, 50, 70, 20);
- gui.addRadiobutton("myRBN3", "On", "motor2", 550, 35, 70, 20);
- gui.addRadiobutton("myRBN4", "Off", "motor2", 550, 55, 70, 20);
- gui.addRadiobutton("myRBN5", "On", "motor3", 680, 170, 70, 20);
- gui.addRadiobutton("myRBN6", "Off", "motor3", 680, 190, 70, 20);
- gui.setState("myRBN2", true);
- gui.setState("myRBN4", true);
- gui.setState("myRBN6", true);
- gui.setAllBackgrounds(255,255,255);
- //Start Touch Sensor
- nxt.getButtonState(0);
- //Start Sound Sensor
- nxt.getDB(1);
- //Start Light Sensor
- nxt.getLight(2);
- //Start Distance Sensor
- nxt.getDistance(3);
- }
I occured this error
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 5
at NXTSVV.setup(NXTSVV.java:57)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
It seems to me that the problem comes of the serial communication tool (line 30 in the code). But i really don't know, I have not used a lot the nxt brick.
Well if Someone have a clue it’s welcome.
I’m really looking forward to have this P5 control tool running so i will keep on searching.
I’m very enthusiastic about this project
1