Created
January 15, 2013 02:26
-
-
Save fcastellanos/4535499 to your computer and use it in GitHub Desktop.
Small Ruby app to show the PhidgetsRFID reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'phidgets-ffi' | |
puts "Library Version: #{Phidgets::FFI.library_version}" | |
rfid = Phidgets::RFID.new | |
puts "Wait for PhidgetRFID to attached..." | |
#The following method runs when the PhidgetRFID is attached to the system | |
rfid.on_attach do |device, obj| | |
rfid.antenna = true | |
rfid.led = true | |
sleep 1 | |
end | |
rfid.on_tag do |device, tag, obj| | |
puts "Tag #{tag} detected" | |
end | |
rfid.on_tag_lost do |device, tag, obj| | |
puts "Tag #{tag} removed" | |
end | |
puts "Please insert a tag to read read ..." | |
gets.chomp | |
puts 'Closing...' | |
rfid.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment