Skip to content

Instantly share code, notes, and snippets.

@fcastellanos
Created January 15, 2013 02:26
Show Gist options
  • Save fcastellanos/4535499 to your computer and use it in GitHub Desktop.
Save fcastellanos/4535499 to your computer and use it in GitHub Desktop.
Small Ruby app to show the PhidgetsRFID reader
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