IEEE Spectrum November, 2016 - 21

A DIY Lego
ControLLer
A low-cost wAy
to progrAm lego
mAchines

f you want to explore coding with Lego bricks, there's one major option:
to use a kit from the company's well-known Mindstorms robotics line. Mindstormsbased machines are built around the Intelligent Brick, which can be programmed
using Lego's graphical programming environment or one of a number of third-party alternative languages. But Lego also makes a collection of motors, connectors, lights, and infrared receivers collectively sold under the label of Power Functions. In place of a programmable brick, the Power Function line includes a handheld controller for transmitting command signals. I wondered if it was possible
to use a Raspberry Pi to replace the handheld controller, taking on the role of an Intelligent Brick. This would have some advantages.
With programs being created on the same device used to control Lego constructions, it would eliminate the need to download the programs to the brick, speeding up development. The US $40 Pi is also a lot cheaper than the $190 Intelligent Brick. I also wondered if
such a setup could be used with MIT's Scratch, a free visual programming environment aimed at children. Scratch extensions are available for use with the Mindstorms brick, but they require altering the brick's firmware, and I wanted to try something simpler. As I discovered, most of the code required for controlling Lego toys using Scratch is already available as open source software. What was

RESOURCES_hANDS ON

I

DiomiDis spinellis

*

*

SPECTRUM.IEEE.ORG

|

NORTh AMERICAN

|

NOV 2016

|

21


http://SPECTRUM.IEEE.ORG

Table of Contents for the Digital Edition of IEEE Spectrum November, 2016

IEEE Spectrum November, 2016 - Cover1
IEEE Spectrum November, 2016 - Cover2
IEEE Spectrum November, 2016 - 1
IEEE Spectrum November, 2016 - 2
IEEE Spectrum November, 2016 - 3
IEEE Spectrum November, 2016 - 4
IEEE Spectrum November, 2016 - 5
IEEE Spectrum November, 2016 - 6
IEEE Spectrum November, 2016 - 7
IEEE Spectrum November, 2016 - 8
IEEE Spectrum November, 2016 - 9
IEEE Spectrum November, 2016 - 10
IEEE Spectrum November, 2016 - 11
IEEE Spectrum November, 2016 - 12
IEEE Spectrum November, 2016 - 13
IEEE Spectrum November, 2016 - 14
IEEE Spectrum November, 2016 - 15
IEEE Spectrum November, 2016 - 16
IEEE Spectrum November, 2016 - 17
IEEE Spectrum November, 2016 - 18
IEEE Spectrum November, 2016 - 19
IEEE Spectrum November, 2016 - 20
IEEE Spectrum November, 2016 - 21
IEEE Spectrum November, 2016 - 22
IEEE Spectrum November, 2016 - 23
IEEE Spectrum November, 2016 - 24
IEEE Spectrum November, 2016 - 25
IEEE Spectrum November, 2016 - 26
IEEE Spectrum November, 2016 - 27
IEEE Spectrum November, 2016 - 28
IEEE Spectrum November, 2016 - 29
IEEE Spectrum November, 2016 - 30
IEEE Spectrum November, 2016 - 31
IEEE Spectrum November, 2016 - 32
IEEE Spectrum November, 2016 - 33
IEEE Spectrum November, 2016 - 34
IEEE Spectrum November, 2016 - 35
IEEE Spectrum November, 2016 - 36
IEEE Spectrum November, 2016 - 37
IEEE Spectrum November, 2016 - 38
IEEE Spectrum November, 2016 - 39
IEEE Spectrum November, 2016 - 40
IEEE Spectrum November, 2016 - 41
IEEE Spectrum November, 2016 - 42
IEEE Spectrum November, 2016 - 43
IEEE Spectrum November, 2016 - 44
IEEE Spectrum November, 2016 - 45
IEEE Spectrum November, 2016 - 46
IEEE Spectrum November, 2016 - 47
IEEE Spectrum November, 2016 - 48
IEEE Spectrum November, 2016 - 49
IEEE Spectrum November, 2016 - 50
IEEE Spectrum November, 2016 - 51
IEEE Spectrum November, 2016 - 52
IEEE Spectrum November, 2016 - 53
IEEE Spectrum November, 2016 - 54
IEEE Spectrum November, 2016 - 55
IEEE Spectrum November, 2016 - 56
IEEE Spectrum November, 2016 - 57
IEEE Spectrum November, 2016 - 58
IEEE Spectrum November, 2016 - 59
IEEE Spectrum November, 2016 - 60
IEEE Spectrum November, 2016 - 61
IEEE Spectrum November, 2016 - 62
IEEE Spectrum November, 2016 - 63
IEEE Spectrum November, 2016 - 64
IEEE Spectrum November, 2016 - 65
IEEE Spectrum November, 2016 - 66
IEEE Spectrum November, 2016 - 67
IEEE Spectrum November, 2016 - 68
IEEE Spectrum November, 2016 - 69
IEEE Spectrum November, 2016 - 70
IEEE Spectrum November, 2016 - 71
IEEE Spectrum November, 2016 - 72
IEEE Spectrum November, 2016 - 73
IEEE Spectrum November, 2016 - 74
IEEE Spectrum November, 2016 - 75
IEEE Spectrum November, 2016 - 76
IEEE Spectrum November, 2016 - Cover3
IEEE Spectrum November, 2016 - Cover4
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1217
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1117
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1017
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0917
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0817
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0717
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0617
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0517
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0417
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0317
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0217
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0117
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1216
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1116
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1016
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0916
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0816
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0716
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0616
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0516
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0416
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0316
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0216
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0116
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1215
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1115
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1015
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0915
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0815
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0715
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0615
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0515
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0415
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0315
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0215
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0115
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1214
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1114
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1014
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0914
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0814
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0714
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0614
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0514
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0414
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0314
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0214
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0114
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1213
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1113
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1013
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0913
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0813
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0713
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0613
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0513
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0413
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0313
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0213
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0113
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1212
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1112
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1012
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0912
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0812
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0712
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0612
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0512
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0412
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0312
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0212
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0112
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1211
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1111
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1011
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0911
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0811
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0711
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0611
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0511
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0411
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0311
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0211
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0111
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1210
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1110
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1010
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0910
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0810
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0710
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0610
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0510
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0410
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0310
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0210
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0110
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1209
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1109
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1009
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0909
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0809
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0709
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0609
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0509
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0409
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0309
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0209
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0109
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1208
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1108
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1008
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0908
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0808
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0708
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0608
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0508
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0408
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0308
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0208
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0108
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1207
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1107
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1007
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0907
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0807
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0707
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0607
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0507
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0407
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0307
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0207
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0107
https://www.nxtbookmedia.com