Sha256: 983bdcb89c07bf922e297539a6cdfa8d058be6500805b0771601100ea1095f7e

Contents?: true

Size: 647 Bytes

Versions: 11

Compression:

Stored size: 647 Bytes

Contents

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

# arduino = ArduinoFirmata.connect
arduino = ArduinoFirmata.connect nil, :nonblock_io => true, :eventmachine => true

get '/' do
  redirect './on'
end

get '/on' do
  analog = arduino.analog_read(0)
  arduino.digital_write 13, ArduinoFirmata::HIGH
  "<p>analog : #{analog}</p><p><a href='./off'>LED OFF</a></p>"
end

get '/off' do
  analog = arduino.analog_read(0)
  arduino.digital_write 13, ArduinoFirmata::LOW
  "<p>analog : #{analog}</p><p><a href='./on'>LED ON</a></p>"
end

Version data entries

11 entries across 11 versions & 1 rubygems

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