Text
Page: 1
Embedded Ruby Revolution:
A Hands-On Workshop
with PicoRuby
hasumikin
EuRuKo 2024 in Sarajevo
12 Sept 2024
Page: 2
self.inspect
Hitoshi HASUMI
@hasumikin (GitHub and Twitter)
Creator of PicoRuby
Contributor to CRuby and mruby
Member of IRB maintainer team
Page: 3
Agenda
Introduction to PicoRuby
Quick Demo
Hands-On Workshop
LED Blinking, Temperature Sensor,
LCD Display, then All Work Together
Including basic training on microcontroller
Page: 5
Introduction to PicoRuby
Page: 6
What is PicoRuby?
Smallest Ruby implementation for microcontrollers
Based on mruby’s VM code design
Targeting RP2040 (so far)
Parser: Prism, merged this week
Used be my own parser
Now almost full-compatible with CRuby!!!
Page: 7
RP2040 and Raspberry Pi Pico
Raspberry Pi Pico: Microcontroller board
MCU: RP2040
Cortex-Mzero+ (dual)
264 KB RAM, 2 MB flash ROM
Generally runs without an OS
Completely different from
Raspberry Pi (Single Board Computer)
RP2040
Page: 9
What You Saw in the Demo
Unix-like shell running on Raspberry Pi Pico
You can use some commands like cd, ls, mkdir, and
irb
In IRB, your Ruby snippet is compiled into mruby VM
code and executed on the fly
If you put /home/app.rb, it will be executed
automatically on startup
Page: 10
Hands-On Workshop
Page: 11
Please check: All parts are ready
Page: 12
You can take this kit home with you!
It’s a gift from ITOC, a research institute in Shimane
Prefecture (the most beautiful prefecture in Japan, where
Matz and I live)!
Page: 13
Mutual Support Is Essential
For A Successful Workshop!
Page: 14
Hands-On 1: Setup and LED Blinking
LED is the most basic component in electronics
You can control the LED by GPIO pins
Page: 15
Hands-On 2: RGB LED Fading
You can control the brightness of the LED by PWM
It simulates analog output by changing the duty cycle of
the signal
Page: 16
Hands-On 3: Temperature Sensor
Thermistor is a resistor whose resistance changes with
temperature
You can read the resistance via ADC
Page: 17
Hands-On 4: Character Display
I2C is one of the serial communication protocols
Low-level operation is messy, so you might want to use a
library (gem)
Page: 18
Hands-On 5: Talk to Your Neighbor
UART is another serial communication protocol
Let’s talk to your neighbor’s Pico through UART!
Page: 19
Hands-On 6: All Work Together
Make a new project with your own idea
Share your cool PicoRuby application with us!
Resouces:
https://tinyurl.com/picoruby-setup
https://tinyurl.com/picoruby-led
https://tinyurl.com/picoruby-rgb
https://tinyurl.com/picoruby-temp
https://tinyurl.com/picoruby-lcd
https://tinyurl.com/picoruby-uart
Page: 20
Stargaze at
github.com/picoruby/picoruby
Thank you!