Sha256: c4ab8cfe044097c6f8cf93567037ebdd4e71af38862ba914af0dbfef21476528

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

arduino_firmata
===============

* Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
* http://shokai.github.com/arduino_firmata


Install
-------

    % gem install arduino_firmata


Requirements
------------

* Arduino Standard Firmata v2.2
  * Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata]
* Ruby 1.8.7+
* Ruby 1.9.2+


Synopsis
--------

Setup
```ruby
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
```

Board Version
```ruby
puts "firmata version #{arduino.version}"
```

Digital Write
```ruby
arduino.digital_write 13, true
arduino.digital_write 13, false
```

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

Analog Write (PWM)
```ruby
0.upto(255) do |i|
  arduino.analog_write 11, i
  sleep 0.01
end
```

Analog Read
```ruby
puts arduino.analog_read 0  # => 0 ~ 1023

arduino.on_analog_changed 0 do |value|
  puts value  # => 0 ~ 1023
end
```

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

Close
```ruby
arduino.close
```

Block
```ruby
ArduinoFirmata.connect do
  puts "firmata version #{version}"

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


see samples https://github.com/shokai/arduino_firmata/tree/master/samples


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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arduino_firmata-0.1.8 README.md
arduino_firmata-0.1.7 README.md