Sha256: 2f5bb295fe19466db695851c68b80ca32b04fd830e7a55a7c7f935cf0c2ba415

Contents?: true

Size: 428 Bytes

Versions: 9

Compression:

Stored size: 428 Bytes

Contents

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

arduino = ArduinoFirmata.connect ARGV.shift
arduino.pin_mode 2, ArduinoFirmata::INPUT

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

led_stat = false
loop do
  arduino.digital_write 13, led_stat
  led_stat = !led_stat
  sleep 1
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
arduino_firmata-0.2.9 samples/on_digital_read.rb
arduino_firmata-0.2.8 samples/on_digital_read.rb
arduino_firmata-0.2.7 samples/on_digital_read.rb
arduino_firmata-0.2.6 samples/on_digital_read.rb
arduino_firmata-0.2.5 samples/on_digital_read.rb
arduino_firmata-0.2.4 samples/on_digital_read.rb
arduino_firmata-0.2.3 samples/on_digital_read.rb
arduino_firmata-0.2.2 samples/on_digital_read.rb
arduino_firmata-0.2.1 samples/on_digital_read.rb