Introducing Rubyduino, a Ruby to Arduino UNO compiler based on Matz's Spinel!

Published: (May 8, 2026 at 02:16 PM EDT)
1 min read
Source: Dev.to

Source: Dev.to

Cover image for Introducing Rubyduino, a Ruby to Arduino UNO compiler based on Matz's Spinel!

Overview

Rubyduino (GitHub) compiles Ruby sketches for Arduino boards and uploads the generated firmware. Under the hood it uses Spinel, Matz’s Ruby AOT compiler, vendored at a pinned revision.

How it works?

Rubyduino adds a small Arduino runtime on top of the C code generated by Spinel. Functions such as digital_write, delay_ms, analog_read, serial_print, and pulse_in are mapped to tiny AVR C functions that interact directly with the Arduino UNO hardware registers.

The normal AVR toolchain then takes over:

  1. Ruby sketch → Spinel turns it into C
  2. Rubyduino adds the Arduino UNO runtime
  3. avr-gcc compiles the C into firmware
  4. avrdude uploads the firmware to the board

The Arduino is not interpreting Ruby; it runs compiled AVR machine code that originated as Ruby. No Firmata or RAD is involved—this is a brand‑new approach.

Tutorial

gem install rubyduino
touch blink.rb
# blink.rb
pin_mode(ArduinoUNO::LED_BUILTIN, ArduinoUNO::OUTPUT)

loop do
  digital_write(ArduinoUNO::LED_BUILTIN, ArduinoUNO::HIGH)
  delay_ms(100)
  digital_write(ArduinoUNO::LED_BUILTIN, ArduinoUNO::LOW)
  delay_ms(100)
end
rubyduino blink.rb

Result:

Arduino is blinking

0 views
Back to Blog

Related posts

Read more »

Bun ported to Rust in 6 days

Overview - Test coverage: 99.8 % of Bun’s pre‑existing test suite passes on Linux x64 glibc in the Rust rewrite. - The codebase is essentially the same, but Ru...