Controlling a Lego NXT Robot with python

Controlling an NXT Robot with python (on MacOSX)

Install Brew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor

Install libusb

brew install libusb

Install PyUSB

To test if it works:

import usb.core
usb.core.find()

<DEVICE ID 0694:0002 on Bus 020 Address 005>

Install NXT Python

To test if it works, connect a brick and attach a motor to port A:

import nxt.locator
import nxt.motor
b = nxt.locator.find_one_brick()
m = nxt.motor.Motor(b, nxt.motor.PORT_A)
m.turn(50,360)

The motor should rotate 360 degrees