Copyright © Astro Designs Ltd. Registered office, Marlborough, Wilts. England

Mail: Designs Website (

Lego Mindstorm NXT Controller

This is a great little project to highlight some of the great features of the PiXi-200. This project allows the Raspberry Pi to control up to eight Lego Mindstorm NXT motors and read up to eight Lego Mindstorm NXT sensors simultaneously and still have room for more functions. Perfect for building a Lego robot!

For the sensor interface, the PiXi-200 can provide eight separate I2C interfaces on it’s GPIO3 I/O port and since this interface can be powered from 3.3v or 5v this interface can connect directly to the I2C ports on the Lego Mindstorm NXT sensors with only a pull-up resistor to the 5v supply rail. There are also eight analogue (ADC) ports on the PiXi-200 which allows up to 8 analogue sensors to be used.

For the motor interface we could do this two ways… Firstly we could use the 16 open-collector outputs on GPIO2 plus 8 outputs on GPIO1 to drive four L293 or similar quad half-H motor drivers which would allow up to eight motors to be driven. The tacho interface from each motor simply needs a signal level reduction using a simple potential divider network to allow it to be connected directly to the 3.3v GPIO1 I/O port. A clamp diode to the 3.3v rail is recommended to protect the FPGA against any over-voltage on this port. Or we can do it using the eight on-board 2A open-drain MOSFETS plus external relays in place of the L293. In this case the relay would used to change-over the connections to the motor to change the motor direction while the on-board 2A MOSFETS can be use to enable the motor and control the motor speed using pulse-width modulation. This also has the benefit that it saves one signal per motor as the enable & PWM controls are combined into a single signal.

This potentially leaves eight general-purpose I/O pins available on GPIO1 to be used for other functions - lamp drivers, LED drivers, switch sensors etc. Plus there’s still the 2mm 10-way differential / 20-way single-ended expansion interface available, the SPI interface or 5 general-purpose I/O pins on the expansion interface and the dedicated I2C port on GPIO3 so there’s plenty of room for expansion!

And not forgetting that it has a built-in accelerometer, gyroscope and magnetometer for motion sensing and navigation functions.

Control your project over the network, Internet or simply use the on-board RS232 serial interface.

It would need some external hardware but this would be limited to the L293 motor drivers (x4) or up to eight relays, a few resistors and protection diodes to bring the 5v tacho signals down to 3.3v and a few optional links to allow the sensor interface type to be selected.

Eight Lego motors plus eight Lego sensors, built-in positional sensing and still some general purpose I/O to play with… All controllable from one Raspberry Pi and a PiXi-200… Check-out the PiXi-200 gallery for a photo of a cut-down version of this project providing two motor controller ports and two sensor ports.

Techy-hint: Don’t get bogged down trying to locate the custom Lego Mindstorm NXT RJ12-like sockets for your project, do what we did and just get yourself a normal Lego Mindstorm NXT cable, cut one end off and replace it with a standard RJ12 connector. Better still, get a long enough Lego Mindstorm NXT cable, cut it in half and turn it into two shorter leads by fitting a standard RJ12 connectors onto the open ends. Then you only need to fit a standard RJ12 socket on your own project board.

Please see the photos’s in the PiXi-200 gallery for a picture of the Lego Mindstorm NTX controller project and there’s a YouTube video here…

Got any thoughts or questions about this project or want some advice? Feel free to email us at