Giter Site home page Giter Site logo

ruby-firmata's Introduction

Firmata

A Ruby implementation of the Firmata protocol.

This library is inspired by the awesome firmata by jgautier.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'firmata'

And then execute:

$ bundle

Or install it yourself as:

$ gem install firmata

Prerequisites

  1. Download the Arduio IDE for your OS
  2. Plug in your Arduino via USB
  3. Open the Arduino IDE, select: File > Examples > Firmata > StandardFirmata
  4. Click the Upload button
  5. Make note of the serial port: Tools > Serial Port

There have been reports of issues with Firmata 2.3. Try downgrading to Firmata 2.2 if you're having a problem.

Usage

Here is a simple example using IRB that will turn pin 13 on and off. (Replace xxxxx with the USB port from step 5 in Prerequisites)

1.9.3p194 :001 > require 'firmata'
1.9.3p194 :002 > board = Firmata::Board.new('/dev/tty.usbmodemxxxxx')
1.9.3p194 :003 > board.connect
1.9.3p194 :004 > board.connected?
 => true
1.9.3p194 :005 > board.version
 => "2.3"
1.9.3p194 :006 > board.firmware_name
 => "StandardFirmata"
1.9.3p194 :007 > board.digital_write(13, Firmata::Board::HIGH)
1.9.3p194 :008 > board.digital_write(13, Firmata::Board::LOW)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

ruby-firmata's People

Contributors

deadprogram avatar hardbap avatar jeg2 avatar josephschito avatar rafmagana avatar shokai avatar zankich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-firmata's Issues

blink_led.rb does not run with ruby 2.2

I get this error while trying to run the blink_led.rb program with ruby 2.2, but ruby 2.1.4 works fine.

$ bundle exec ruby examples/blink_led.rb 
/home/adrian/code/hybridgroup/ruby-firmata/lib/firmata/board.rb:443:in `trap': Invalid argument - SIGKILL (Errno::EINVAL)
        from /home/adrian/code/hybridgroup/ruby-firmata/lib/firmata/board.rb:443:in `block in trap_signals'
        from /home/adrian/code/hybridgroup/ruby-firmata/lib/firmata/board.rb:442:in `each'
        from /home/adrian/code/hybridgroup/ruby-firmata/lib/firmata/board.rb:442:in `trap_signals'
        from /home/adrian/code/hybridgroup/ruby-firmata/lib/firmata/board.rb:42:in `initialize'
        from examples/blink_led.rb:9:in `new'
        from examples/blink_led.rb:9:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.