Skip to main content
Open the door of embedded systems to IoT (the Internet of things)! 
mruby on LEGO Mindstorms EV3 ® 
Takehiko YOSHIDA 
@chihayafuru
Agenda 
Self-introduction 
What's LEGO Mindstorms 
◦Standard Programming Environment 
◦Extended Programming Environment (ev3dev) 
Can we use mruby in embedded systems? 
◦Example of a light sensor for Mindstorms RCX 
◦APIs for EV3s color sensor implemented with mruby 
Concluding Remarks 
Demonstration of the "RUBY JINJA"
Self-introduction 
I'm from Matsumoto city, Nagano. 
I work in a manufacturer of information- related equipment as a programmer. 
Takehiko YOSHIDA 
@chihayafuru
A hierarchy of 
a Japanese manufacturing industry 
Samurai 
Farmer 
Artisan 
Trader 
Mechanical Engineer 
Electrical Engineer 
Software Engineer
What's LEGO Mindstorms 
Educational Tool>Toy 
STEM education 
◦Science 
◦Technology 
◦Engineering 
◦Mathematics
History of LEGO Mindstorms 
1st gen. 
MindstormsRCX 
2nd gen. 
MindstormsNXT 
3rd gen. 
Mindstorms EV3 
ReleaseDATE 
1998 
2006 
2013 
CPU 
H816MHz 
ARM7 
48 MHz 
ARM9 
300 MHz 
RAM 
32 KB 
64 KB 
16 MB
Standard Firmware Architecture 
OS (Linux) 
System 
Program 
Device driver (kernel module) 
VM (Virtual Machine) 
User 
Program 
Direct 
Command
Extended Firmware 
ev3dev 
◦full Debian 7 (wheezy) Linux Distribution. 
◦customized for the LEGO MINDSTORM EV3 controller. 
◦Bootable from microSD/SDHC card 
Available Programming Language 
C / C++ 
Python 
JavaScript (Node.js) 
Lua 
Go 
Ruby
What's mruby ? 
mruby is the lightweight implementation of Ruby language complying to (part of) the ISO standard. Its syntax is Ruby 1.9 compatible. 
mruby can be linked and embedded into your application. 
https://github.com/mruby/mruby
Can we use "mruby" in embedded systems ? 
Real-time constraint 
•Can mruby meet the deadline ? 
•A process of GC (Garbage Collection) deactivate other interrupts.
An example of a light sensor for1st gen. Mindstorms RCX 
LED Light 
Photo Detector
Circuit diagram of general light sensor 
Signal 
Power 
Common 
Out 
In 
LED 
Photodiode 
(Photo Detector)
Connector of Mindstorms RCX
Circuit diagram of the RCX’s light sensor 
Signal 
Power 
Common 
Out 
In
Waveforms of a signal voltage from the Light Sensor for RCX 
Oscilloscope 
reflected light is strong 
reflected light is weak
delay of programmed cycle
Color Sensor API with mruby for Mindstorms EV3
Initializer of Color sensor 
Ev3Color.new(port) 
port : "in1", "in2", "in3" , "in4"
Connector of Mindstorms EV3
3 modes of Color Sensor 
Ev3Color#mode=(mode) 
EV3Color.Mode.COL-REFLECT 
EV3Color.Mode.COL-AMBIENT 
EV3Color.Mode.RGB-RAW
Evolution of Mindstorms 
Intelligent 
Brick 
Light 
Sensor 
1st gen. 
Mindstorms RCX 
2nd gen. 
Mindstorms NXT 
3rd gen. 
Mindstorms EV3 
ANALOG 
ANALOG 
DIGITAL
Concluding Remarks 
What is mruby suitable for ? 
What is mruby NOT suitable for ?
What is mruby NOT suitable for ? 
Reaching a hardware limit under software control. 
Be willing to work in the background of mechanics and electronics, and struggle with C/C++, assembly language.
What is mrubysuitable for ? 
High-functional / Multi-functional electric devices 
Newly-developed Cloud servicesCreating new value with mashup technology
References 
LEGO Mindstorms® 
http://www.lego.com/en-us/mindstorms/ 
ev3dev 
http://www.ev3dev.org/ 
mruby 
https://github.com/mruby/mruby 
mruby-ev3dev 
https://github.com/chihayafuru/mruby-ev3dev