Home

Awesome

denko

Test Status

Program real-life electronics in Ruby. LEDs, buttons, sensors (and more) work just like any Ruby object:

led.blink 0.5

lcd.print "Hello World!"

reading = sensor.read

button.down do
  puts "Button pressed!"
end

How It Works

There are currently two ways to use denko. Both have the same user-friendly API, but the hardware can be very different. Here's a summary of each:

Connected Microcontroller

Single-Board-Computer

Notes:

Supported Hardware

Microcontroller & Peripheral Support List

Installation

Note: On Windows you can follow the Mac/Linux instructions in WSL, but it isn't recommended. Serial (COM port) forwarding isn't working on WSL2, which means you can't communicate with the board. There are workarounds, and it might work on WSL1, but the RubyInstaller for Windows and Arduino IDE are recommended instead. A Linux virtual machine with USB passthrough works too.

1. Install the Gem

gem install denko

2. Install the Arduino IDE OR CLI

Get the Arduino IDE here for a graphical interface (recommended for Windows), or use the command line interface from here, or Homebrew.

CLI Installation with Homebrew on Mac or Linux:

brew update
brew install arduino-cli

3. Install Arduino Dependencies

Denko uses Arduino cores, which support different microcontrollers, and a few libraries. Install only the ones for your microcontroller, or install everything. There are no conflcits. Instructions:

4. Generate the Arduino Sketch

The denko command is included with the gem. It will make the Arduino sketch folder for you, and configure it.

Example for ESP32 target on both serial and Wi-Fi:

denko sketch serial --target esp32
denko sketch wifi --target esp32 --ssid YOUR_SSID --password YOUR_PASSWORD

# For more options
denko targets

Note: Boards flashed with a Wi-Fi or Ethernet sketch will listen for a TCP connection, but fall back to Serial when there is none active.

5a. IDE Flashing

Troubleshooting:

5b. CLI Flashing

arduino-cli board list
arduino-cli compile -b YOUR_FQBN YOUR_SKETCH_FOLDER
arduino-cli upload -v -p YOUR_PORT -b YOUR_FQBN YOUR_SKETCH_FOLDER

Troubleshooting:

arduino-cli board listall

6. Test It

Most boards have a regular LED on-board. Test with the blink example. If you have an on-board WS2812 LED (Neopixel), use the WS2812 blink example instead. If it starts blinking, you're ready for Ruby!

Examples and Tutorials

Tutorial

Included Examples