• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 12 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Arduino Firmata protocol implementation on Ruby

arduino_firmata

Arduino Firmata protocol (http://firmata.org) implementation on Ruby.

  • Firmata is a protocol to controll Arduino from software on PC.
  • You can embed Arduino code into Ruby application.
  • Support sharing an Arduino between multiple processes.
  • http://shokai.github.io/arduino_firmata

Install

% gem install arduino_firmata

Requirements

  • Ruby 1.8.7 or 1.9.2 or 1.9.3 or 2.0.0
  • Arduino (http://arduino.cc)
    • testing with Arduino Diecimila, Duemillanove, UNO, Leonardo, Micro and Seeduino v2.
  • Arduino Standard Firmata v2.2
    • Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata]

ArduinoFirmata Command

% arduino_firmata --help
% arduino_firmata --list
% arduino_firmata digital_write 13, true
% arduino_firmata analog_read 0
% arduino_firmata servo_write 9, 145

Synopsis

Setup

Connect

require 'arduino_firmata'

arduino = ArduinoFirmata.connect  # use default arduino
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name'
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name', :bps => 57600
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name', :nonblock_io => true
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name', :eventmachine => true

Board Version

puts "firmata version #{arduino.version}"

Close

arduino.close

I/O

Digital Write

arduino.digital_write 13, true
arduino.digital_write 13, false

Digital Read

arduino.pin_mode 7, ArduinoFirmata::INPUT
puts arduino.digital_read 7  # => true/false

## regist event
arduino.on :digital_read do |pin, status|
  if pin == 7
    puts "digital pin #{pin} changed : #{status}"
  end
end

Analog Write (PWM)

0.upto(255) do |i|
  arduino.analog_write 11, i
  sleep 0.01
end

Analog Read

puts arduino.analog_read 0  # => 0 ~ 1023

## regist event
arduino.on :analog_read do |pin, value|
  if pin == 0
    puts "analog pin #{pin} changed : #{value}"
  end
end

Servo Motor

loop do
  angle = rand(180)
  arduino.servo_write 11, angle
  sleep 1
end

Sysex

Send

arduino.sysex 0x01, [13, 5, 2]  # command, data_array

Regist Receive Event

arduino.on :sysex do |command, data|
  puts "command : #{command}"
  puts "data    : #{data.inspect}"
end

Block Style

ArduinoFirmata.connect do
  puts "firmata version #{version}"

  30.times do
    an = analog_read 0
    analog_write 11, an
    sleep 0.01
  end
end

Test

Install SysexLedBlinkFirmata into Arduino

Run Test

% gem install bundler
% bundle install
% export ARDUINO=/dev/tty.usb-device-name
% rake test

Contributing

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

More Repositories

1

tw

Twitter client on Ruby.
Ruby
152
star
2

websocket-client-simple

Simple WebSocket Client on Ruby
Ruby
111
star
3

jQuery.editable

edit in place plugin for jQuery
JavaScript
101
star
4

ArduinoFirmata-Android

Arduino Firmata protocol implementation on Android Java.
Java
67
star
5

sinatra-rocketio

WebSocket/Comet plugin for Sinatra.
Ruby
64
star
6

hubot-rss-reader

RSS Reader on Hubot
CoffeeScript
63
star
7

ruby-socket.io-client-simple

A simple ruby client for node.js's socket.io. Supports only WebSocket.
Ruby
61
star
8

skype-ruby

Deprecated. MS removed API
Ruby
61
star
9

node-arduino-firmata

Arduino Firmata protocol implementation on Node.js
CoffeeScript
51
star
10

theta-viewer.js

Animate multiple-Photos taken by Ricoh THETA
JavaScript
49
star
11

serialport-server

SerialPort Server makes your Device (Arduino, mbed...) WebServer. You can access SerialPort via HTTP, WebSocket and TCP Socket.
Ruby
44
star
12

event_emitter

Ruby port of EventEmitter from Node.js
Ruby
42
star
13

ruby-irkit

IRKit Client for Ruby
Ruby
36
star
14

ruby-wav-file

read wav file format and edit data chunk
Ruby
36
star
15

node-ricoh-theta

controll RICOH THETA 360-degree camera with Node.js
CoffeeScript
31
star
16

socket.io-request

bi-directional request-response for socket.io
JavaScript
30
star
17

nhk-news-app

auto play NHK News using node-webkit
CoffeeScript
29
star
18

korg-nano-kontrol

Node.js/Browser library for KORG nanoKONTROL and nanoKONTROL2.
JavaScript
28
star
19

node-asearch

Approximate pattern matching on JavaScript
JavaScript
27
star
20

sinatra-template

Simple Sinatra App Template
Ruby
25
star
21

react-display-switch

Declarative React Components for improving readability by eliminating { }, && and ternary operators out of JSX
JavaScript
23
star
22

leapmotion-ruby

LeapMotion WebSocket wrapper for Ruby
Ruby
23
star
23

arduino_ir_remote

IR Learning Remote with Arduino and Ruby
Ruby
19
star
24

node-philips-hue

Node.js library for Philips Hue bridge API
JavaScript
17
star
25

skype-socket-gateway

Skype API <---> TCP Socket
Ruby
17
star
26

android-gpstracker

Java
16
star
27

semirara

deprecated. go https://scrapbox.io
JavaScript
16
star
28

cpp-libboost-study

boost c++ libのお勉強
C++
16
star
29

theta-live-viewer

RICOH THETA Live Camera App
JavaScript
15
star
30

hubot-mongodb-brain

MongoDB brain for Hubot
CoffeeScript
15
star
31

node-gyazo-api

Gyazo API wrapper for Node.js
JavaScript
15
star
32

nfctag-server

read NFC Tag via HTTP, WebSocket and TCP Socket
Ruby
14
star
33

phonegap-plugin-nfc

Android NFC Plugin for PhoneGap
Java
14
star
34

video2gif

convert video to anime gif
Ruby
13
star
35

twitter-egosearch-slack

search on Twitter and notify with Slack
Ruby
12
star
36

iphone-js-console

JavaScript interactive shell for iPhone
JavaScript
12
star
37

wifi_location

Get your location with WiFi Mac Address and GoogleMap.
Ruby
12
star
38

node-slackbot

Slackbot wrapper for slack.com
CoffeeScript
11
star
39

blendmicro-node

Node.js module for BlendMicro/BLENano with BLE
CoffeeScript
11
star
40

async-throttle

make async/promise function execute only one at a time.
JavaScript
10
star
41

twiticon

Twitter Profile Icon with simple URL "http://twiticon.herokuapp.com/USER_NAME"
Ruby
10
star
42

skype-chat-gateway-linux

Skype Chat <--(HTTP)-- Your Apps
Ruby
10
star
43

hue-korg-control

contorll Philips Hue with KORG nanoKontrol
JavaScript
9
star
44

print-server

Print by File uploading or URL posting.
Ruby
9
star
45

hugeurl

expand tinyurl, bit.ly, t.co and more.
Ruby
9
star
46

sinatra-websocketio

WebSocket component for Sinatra RocketIO
Ruby
9
star
47

js-glitchtext

glitch your text
JavaScript
8
star
48

ImageResize-ruby

resize image, use java (deprecated)
Ruby
8
star
49

node-flux-boilerplate

react+fluxxor+socket.io chat
JavaScript
8
star
50

ruby-tiqav

ruby wrapper for tiqav.com
Ruby
8
star
51

ruby-im-kayac

post im.kayac.com
Ruby
7
star
52

digispark-study

DigiSpark Study
Arduino
7
star
53

sinatra-heroku-phantomjs

Sinatra+PhantomJS on Heroku
Ruby
7
star
54

serial-socket-gateway

serial device (/dev/tty.*.usbserial) <---> TCP Socket
Ruby
7
star
55

tiqav-chat

Tiqav+(Node+Express+SocketIO) -> Chat
JavaScript
7
star
56

sinatra-cometio

Comet component for Sinatra RocketIO
Ruby
7
star
57

xframe.js

cross-domain iframe scroll
JavaScript
7
star
58

glitchicon

create glitch icon
Ruby
6
star
59

skype-bots

using skype-socket-gateway
Ruby
6
star
60

java-evmsg

event driven TCP & UDP messaging
Java
6
star
61

ruby-kuro-rs

control KURO-RS and PC-OP-RS1 (IR-LED Remote Controller)
Ruby
6
star
62

gyaazz

JavaScript
6
star
63

sinatra-auto-reload

automatically reload web browser when you save code
Ruby
5
star
64

IRKit-WebUI

IRKit Web Controll UI
Ruby
5
star
65

syslog-client-for-windows

Syslog Client for Windows
Ruby
5
star
66

goldfish

Real-World GUI Framework
Java
5
star
67

ruby-websocket-test

EM::WebSocket
Ruby
5
star
68

rocketio-hello-world

Hello RocketIO
Ruby
5
star
69

tmp_cache

on memory cache
Ruby
5
star
70

camera-server

camera server
Ruby
5
star
71

ofSimpleCamera

Simple Camera App with openFrameworks
C
5
star
72

iBeacon-AndroidScala

iBeacon Receiver for Android Scala
Scala
5
star
73

linda-base

Base for Concurrent/Distributed Computing with Linda
Ruby
5
star
74

event_emitter.js

EventEmitter for WebBrowser
JavaScript
5
star
75

neoyokohama-bot

新横浜情報ボット
JavaScript
4
star
76

sinatra-rocketio-linda

Linda implementation on Sinatra RocketIO
Ruby
4
star
77

hubot-anonymous-post

you can be bot
CoffeeScript
4
star
78

heroku-express-mongo-memo

JavaScript
4
star
79

speech-news

Speech Google News
Ruby
4
star
80

pixiv_crawl

crawl pixiv illusts
Ruby
4
star
81

es6-study

ES6 study
JavaScript
4
star
82

glitchtweet-web-app

glitched twitter client
JavaScript
4
star
83

oden

Search Image on Tiqav.com
Ruby
4
star
84

mac-dot-emacs

dot emacs files on mac
Emacs Lisp
4
star
85

twitter-change-profile

update profile using wikipedia
Ruby
4
star
86

linda-ruby

Tuple and TupleSpace implementation of Linda - coordinational language for parallel processing.
Ruby
4
star
87

quicktime-player-mac

control QuickTime Player on Mac
Ruby
4
star
88

scansnap_adjust_images_kindle

adjust image for scansnap to read on kindle
Ruby
4
star
89

serial-http-gateway

access serial device via HTTP
Ruby
4
star
90

paperget

download pdf files from ACM Portal
Ruby
3
star
91

combine-middlewares

combine middlewares to one chain, supports async-await and recursive.
JavaScript
3
star
92

android-glitchtweet

make glitch tweet on android
Java
3
star
93

github-cmd

github command
Ruby
3
star
94

args_parser

Parse/Filter/Validate ARGV from command line with DSL.
Ruby
3
star
95

ore-api

俺API (Jawbone Up24)
CoffeeScript
3
star
96

notify-server

HTTP ---> (IM, RSS, JSON)
Ruby
3
star
97

audio-play-server

post mp3 URL => play
Ruby
3
star
98

js-iphone-shake-event

catch "shake" event using accelerometer
JavaScript
3
star
99

glitchtweet

make glitch tweet
Ruby
3
star
100

rack-plugin-study

Rack plugin study
Ruby
3
star