Create a streetcar with Lego Mindstorms components and a Raspberry Pi

Lead Image © ingaclemens, 123RF.com

Easy Street

, ,

Wire Lego Mindstorms

The Lego Mindstorms components are very rugged, and because they work with standard Lego blocks, you can make some fun and amazing projects. Even if your Lego Mindstorms EV3 or NXT brick has died, all its sensors and motors will still work with your Raspberry Pi.

The Lego Windstorms EV3 and NXT components can be wired into your Rasp Pi (or Arduino) projects with the use of some custom adapters. If you are brave, you could cut one end off of the connector cables. Unfortunately, we didn't have any extra cables, so we took the safe route and used adapters; specifically, the breadboard version from Dexter Industries [2].

Using the following parts, we were able to make an automated streetcar (Figure 1):

  • 1 Lego Mindstorms motor
  • 2 Lego Mindstorms touch sensors
  • 3 Lego Mindstorms connector cables
  • 3 Dexter Lego Mindstorms breadboard adapters
  • 1 small breadboard
  • 1 Raspberry Pi 3 (or RPi2 with a network connection)
  • 1 Pimoroni Explorer HAT Pro [3]
  • 2 long pieces of wire
  • lots of Lego blocks
Figure 1: Streetcar overview.

Streetcar Design

Our goal for the streetcar project was to have two stations, each with a touch sensor that stopped the streetcar and made it switch directions. Station 1 had the motor, a touch sensor, and the Rasp Pi (Figures 1 and 2). Station 2 had a pulley wheel, a touch sensor, and a small breadboard that was wired back to the Rasp Pi at station 1 (Figure 3). The pulley string went above the streetcar and had to be kept quite tight so the pulley would not slip.

Figure 2: Streetcar station 1.
Figure 3: Streetcar station 2 looking down from the top.

Wiring

All of the Lego Mindstorms wiring used the same pins, labeled "ANG" and "GND" on the left side of the connector. We used an Explorer HAT Pro to connect the Lego Mindstorms motor and touch sensors to the Rasp Pi (Figure 4). As we mentioned earlier, the station 2 touch sensor was wired into a small breadboard. From there, two wires connected it to the Explorer HAT Pro. For our setup, the station 1 touch sensor was wired on Explorer HAT Pro input 1, with station 2 on input 2.

Figure 4: Raspberry Pi Explorer HAT Pro wiring, with the motor on the right and the touch sensors for station 1 (bottom) and station 2 (top) on the left.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content