Sha256: 67d318f85ed494b4ee2f80b3d8651208404be58a898a2fae8203da52144c7d90

Contents?: true

Size: 648 Bytes

Versions: 11

Compression:

Stored size: 648 Bytes

Contents

#!/usr/bin/env ruby
require 'rubygems'
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
require 'eventmachine'
require 'arduino_firmata'

EM::run do
  arduino = ArduinoFirmata.connect ARGV.shift, :nonblock_io => true ,:eventmachine => true

  arduino.on :analog_read do |pin, value|
    puts "analog_read #{pin} => #{value}" if pin == 0
  end

  arduino.pin_mode 2, ArduinoFirmata::INPUT
  arduino.on :digital_read do |pin, status|
    puts "digital_read #{pin} => #{status}" if pin == 2
  end

  led_stat = false
  EM::add_periodic_timer 1 do
    puts led_stat
    arduino.digital_write 13, led_stat
    led_stat = !led_stat
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
arduino_firmata-0.3.7 samples/eventmachine.rb
arduino_firmata-0.3.6 samples/eventmachine.rb
arduino_firmata-0.3.5 samples/eventmachine.rb
arduino_firmata-0.3.4 samples/eventmachine.rb
arduino_firmata-0.3.3 samples/eventmachine.rb
arduino_firmata-0.3.2 samples/eventmachine.rb
arduino_firmata-0.3.1 samples/eventmachine.rb
arduino_firmata-0.3.0 samples/eventmachine.rb
arduino_firmata-0.2.9 samples/eventmachine.rb
arduino_firmata-0.2.8 samples/eventmachine.rb
arduino_firmata-0.2.7 samples/eventmachine.rb