Sha256: 8488f80dddcf505425dc6e4a5d4038f5274042f0d4a15b98255f8c1231f91e57

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

require 'artoo'

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

connection :firmata, :adaptor => :firmata, :port => '/dev/ttyACM0' # linux
#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

2 entries across 2 versions & 1 rubygems

Version Path
artoo-arduino-1.4.4 examples/led_with_button_toggle.rb
artoo-arduino-1.4.3 examples/led_with_button_toggle.rb