Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A ruby library to talk to Arduino without having to burn programs repeatedly to the board

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Arduino ruby gem

This gem is a prototyping API for Arduino in Ruby. Helps prototype Arduino programs quickly from the computer, without the need to burn to the board frequently.


  1. Install the gem: gem install arduino
  2. Load arduino.pde onto your Arduino dev board (just once and for all).
  3. Import the arduino gem: require "arduino"


Initializing:, baudrate)
board ="/dev/ttyUSB1")

Port is something like "/dev/ttyUSB0" on linux and COM*x* (COM1/COM2) on windows. Baudrate is optional. It is 115200 by default.

Setting output pins

The output pins must be set explicitly.


Digital I/O

  1. Arduino.setHigh(pin)
  2. Arduino.setLow(pin)
  3. Arduino.getState(pin) - returns true if pin state is high, else it returns false

Analog I/O

  1. Arduino.analogRead(pin) - returns the analog value
  2. Arduino.analogRead(pin, value) - sets the analog value


1.) Arduino.turnOff - sets all the pins to low state

2.) Arduino.close - closes serial connection. Using this makes sure that you won't have to disconnect & reconnect the Arduino again to recover the serial port.

Usage example

    # This is the blink program.

    require "arduino"

    #specify the port Baudrate is optional and set to 115200 by default
    board ="/dev/ttyUSB1")

    #declare output pins

    #perform operations
    10.times do

Developed for the love of creating stuff by

© 2010 Akash Manohar under the MIT License


Thanks to the following people:

  • @unsymbol - for fixing the Ubuntu reset problem
Something went wrong with that request. Please try again.