= arduino_firmata * http://shokai.github.com/arduino_firmata == INSTALL: * gem install arduino_firmata == DESCRIPTION: Arduino Firmata protocol (http://firmata.org) implementation on Ruby. == REQUIREMENTS: * Arduino Standard Firmata v2.2 Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata] * Ruby 1.8.7+ * Ruby 1.9.2+ == SYNOPSIS: Setup arduino = ArduinoFirmata.connect # use default arduino arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name' Board Version puts "firmata version #{arduino.version}" 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 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 arduino.on_analog_changed 0 do |value| puts value # => 0 ~ 1023 end Servo Motor loop do angle = rand(180) arduino.servo_write 11, angle sleep 1 end Close arduino.close Block 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 == LICENSE: (The MIT License) Copyright (c) 2012 Sho Hashimoto Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.