Sha256: ce4d10772e01485a22da6914395933162b393e5d1c19dc661befc48875a8be40

Contents?: true

Size: 563 Bytes

Versions: 5

Compression:

Stored size: 563 Bytes

Contents

require 'bundler/setup'
require 'firmata'
require 'socket'

sp = TCPSocket.new 'localhost', 8023
board = Firmata::Board.new(sp)

board.connect

puts "Firmware name #{board.firmware_name}"
puts "Firmata version #{board.version}"

pin_number = 2
rate = 0.5

board.on :digital_read do |pin, value|
  puts("#{pin}:#{value}")
end

board.on :digital_read_2 do |value|
  puts "Pin 2: #{value}"
end

board.set_pin_mode(pin_number, Firmata::PinModes::INPUT)
board.toggle_pin_reporting(pin_number)

while true do
  puts "waiting..."
  board.read_and_process
	sleep 0.5
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hybridgroup-firmata-0.4.7 examples/digital_read_socket.rb
hybridgroup-firmata-0.4.6 examples/digital_read_socket.rb
hybridgroup-firmata-0.4.5 examples/digital_read_socket.rb
hybridgroup-firmata-0.4.4 examples/digital_read_socket.rb
hybridgroup-firmata-0.4.3 examples/digital_read_socket.rb