Sha256: b770b5222ae71f1aeeea44519a71e0e0eedd5ceba98eeb0d067120b708dff9ff
Contents?: true
Size: 971 Bytes
Versions: 1
Compression:
Stored size: 971 Bytes
Contents
require 'artoo' # Substitute the button with an analog sensor like a photoresistor and # change to the correct analog input, in this case pin A0. # 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 :sensor, driver: :analog_sensor, pin: 0, interval: 0.25, upper: 900, lower: 200 device :led, :driver => :led, :pin => 8 work do puts puts "Reading sensor in analog pin #{ sensor.pin }" puts "Reading intervals every => #{ sensor.interval }" puts "Initial sensor value => #{ sensor.analog_read(0) }" puts "Sensor upper trigger set at value => #{ sensor.upper }" puts "Sensor lower trigger set at value => #{ sensor.lower }" on sensor, :upper => proc { puts "UPPER LIMIT REACHED!" led.off } on sensor, :lower => proc { puts "LOWER SENSOR LIMIT REACHED!" led.on } end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
artoo-arduino-1.4.4 | examples/analog_sensor.rb |