# Connecting Mindstorm Lego roboter

**URL:** https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354
**Category:** Electronics (Arduino, etc.)
**Created:** [May 1, 2020, 4:15pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354 "2020-05-01T16:15:10Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![kanktonk](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kanktonk](https://discourse.processing.org/u/kanktonk)
#### Post date: [May 1, 2020, 4:15pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/1 "2020-05-01T16:15:10Z")

</div>

Hi im an art student from gemany and im working on a project with processing.  
I have a mistake in my code and I can t figure out how to solve it. If you have any advice it would save me  
a lot of time. I try to connect to my old Mindstorm Lego roboter.  
Processing shows me this Error when i try to run the programm:

> jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> at jssc.SerialPort.openPort(SerialPort.java:164)  
> at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.openPort(Unknown Source)  
> at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.(Unknown Source)  
> at pt.citar.diablu.processing.nxt.LegoNXT.(Unknown Source)  
> at sketch\_200501a.setup(sketch\_200501a.java:60)  
> at processing.core.PApplet.handleDraw(PApplet.java:2432)  
> at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)  
> at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)  
> Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.

I would really appreciate if you can help me!  
This is my code:

```auto
/*
 * NXTCommTest.pde
 *
 * Created on 07 de March 2007
 * Modified on 14 August 2014 
 *
 * NXTComm: A java library to control the NXT Brick.
 * This is part a of the DiABlu Project (http://diablu.jorgecardoso.org)
 *
 * Copyright (C) 2007 Jorge Cardoso
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * You can reach me by
 * email: jorgecardoso <> ieee org
 * web: http://jorgecardoso.org
 */
import processing.serial.*;
import pt.citar.diablu.processing.nxt.*;

int power = 50;
LegoNXT lego;

void setup() {
  size(400, 400);

  lego = new LegoNXT(this, "/dev/tty.NXT-DevB");
  frameRate(10);
}

void draw() {

}

void keyPressed() {
  println(key);

  if (key == '1') {
    lego.motorForwardLimit(LegoNXT.MOTOR_A, power, 360);
  }   
  else if (key == '2') {
    lego.motorForward(LegoNXT.MOTOR_A, power);
  } 
  else if (key == '+') {
    power += 5;
    println(power);
  } 
  else if (key == '-') {
    power -= 5;
    println(power);
  }
  else if (key =='q') {
    lego.motorHandBrake(LegoNXT.MOTOR_A);
  } 
  else if (key == 's') {
    System.out.println("TL: " + lego.getMotorTachoLimit(LegoNXT.MOTOR_A) + 
      " TC: " +lego.getMotorTachoCount(LegoNXT.MOTOR_A) +
      " BTC: " + lego.getMotorBlockTachoCount(LegoNXT.MOTOR_A) + 
      " RC: " + lego.getMotorRotationCount(LegoNXT.MOTOR_A) );
  } else if (key == 'r') {
    lego.resetMotorPosition(LegoNXT.MOTOR_A, false);
  }

}

void stop() {
  println("Stop");
  lego.motorStop(LegoNXT.MOTOR_A);
}

```

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [May 1, 2020, 4:39pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/2 "2020-05-01T16:39:55Z")

</div>

Hello,

Welcome to forum.

Please format your code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 2, 2020, 12:18pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/3 "2020-05-02T12:18:48Z")

</div>

> [@kanktonk](#):
>
> DiABlu Project

maybe you can ask the maker of the DiABlu Project or the writer of the code above.

I don’t know the Lego NXT but maybe you can tell it to clear the port?

Also try another port (physically) on your computer please

---

<div class="post-metadata">

### Author: ![kanktonk](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kanktonk](https://discourse.processing.org/u/kanktonk)
#### Post date: [May 2, 2020, 12:31pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/4 "2020-05-02T12:31:36Z")

</div>

thank you for your awensers, really appreciate it! i tried to rech the maker but he doesn t awenser.  
how do i physically do a port?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 2, 2020, 12:32pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/5 "2020-05-02T12:32:13Z")

</div>

I mean just use another usb port on yor computer

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [May 2, 2020, 12:38pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/6 "2020-05-02T12:38:23Z")

</div>

Hello,

I have already explored the link and tested code examples and can offer my insight.

I can assist if you format your code and delete your duplicate post; please do this as a courtesy to others.  
Try to cut and paste your code and you will see why this is an issue.  
You can go back and edit it.

Also you have a duplicate post:

> [@Coding question for trecking device](https://discourse.processing.org/t/coding-question-for-trecking-device/20385):
>
> Hey I try to use processing together with my old lego mindstorm roboter. I spend a lot of time to research how to combine them and finally found a code online which looked helpfull. But now i get this ERROR can somebody please help me to fix this problem: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy. at jssc.SerialPort.openPort(SerialPort.java:164) at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.openPort(Unkn…

You should delete this.

`:)`

---

<div class="post-metadata">

### Author: ![kanktonk](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kanktonk](https://discourse.processing.org/u/kanktonk)
#### Post date: [May 4, 2020, 8:02am UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/7 "2020-05-04T08:02:30Z")

</div>

hey thanks for your awenser. I format the code now. But when i try to delete the duplicate post it says that I dont have permission.

---

<div class="post-metadata">

### Author: ![kanktonk](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kanktonk](https://discourse.processing.org/u/kanktonk)
#### Post date: [May 4, 2020, 1:20pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/8 "2020-05-04T13:20:35Z")

</div>

ahh ok, unfortunately nothing changed its still the same error

---

<div class="post-metadata">

### Author: ![kanktonk](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kanktonk](https://discourse.processing.org/u/kanktonk)
#### Post date: [May 2, 2020, 11:38am UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/9 "2020-05-02T11:38:05Z")

</div>

Hey I try to use processing together with my old lego mindstorm roboter.  
I spend a lot of time to research how to combine them and finally found a code online which looked helpfull. But now i get this ERROR can somebody please help me to fix this problem:

> jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> at jssc.SerialPort.openPort(SerialPort.java:164)  
> at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.openPort(Unknown Source)  
> at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.(Unknown Source)  
> at pt.citar.diablu.processing.nxt.LegoNXT.(Unknown Source)  
> at sketch\_200502a.setup(sketch\_200502a.java:64)  
> at processing.core.PApplet.handleDraw(PApplet.java:2432)  
> Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)  
> at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.  
> RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [May 8, 2020, 7:02pm UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/10 "2020-05-08T19:02:29Z")

</div>

I merged these posts.

> [@kanktonk](#):
>
> I spend a lot of time to research how to combine them and finally found a code online which looked helpful

@kanktonk – I hope that you were able to resolve your problem. What did you find online? Where? Can you link to that code, and can you paste it here?

---

<div class="post-metadata">

### Author: ![kanktonk](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kanktonk](https://discourse.processing.org/u/kanktonk)
#### Post date: [May 10, 2020, 7:55am UTC](https://discourse.processing.org/t/connecting-mindstorm-lego-roboter/20354/11 "2020-05-10T07:55:07Z")

</div>

Hi jeremy this is what i found [https://www.dexterindustries.com/howto/connect-the-arduino-and-the-lego-mindstorms-together/](https://www.dexterindustries.com/howto/connect-the-arduino-and-the-lego-mindstorms-together/) but i switched to touchdesigner and arduiono which works quite well
