Sha256: b6c322c1e9cdc2f3f45211c8846d5a85a60fb065bdc59b7f6477e675f963cbe0

Contents?: true

Size: 506 Bytes

Versions: 5

Compression:

Stored size: 506 Bytes

Contents

require 'artoo'

# Circuit and schematic here: http://arduino.cc/en/tutorial/button

#connection :firmata, :adaptor => :firmata, :port => '/dev/tty*'
connection :firmata, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :led, :driver => :device_info, :pin => 13
device :button, :driver => :button, :pin => 2, :interval => 0.01

work do
  puts
  puts "Press the button connected on pin #{button.pin}..."

  on button, :push => proc {
    if led.on?
      led.off
    else
      led.on
    end
  }
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
artoo-arduino-1.4.2 examples/led_with_button_toggle.rb
artoo-arduino-1.4.1 examples/led_with_button_toggle.rb
artoo-arduino-1.4.0 examples/led_with_button_toggle.rb
artoo-arduino-1.3.0 examples/led_with_button_toggle.rb
artoo-arduino-1.2.0 examples/led_with_button_toggle.rb