Skip to content

Commit

Permalink
Added demo for k8055 usb interface board
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbroadbent committed Jul 1, 2010
1 parent 48b5b4e commit f9672b4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions octopus_k8055.rb
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
require 'octopus'
require 'rubyk8055'
include USB

@off_delay = 0.4

@r = RubyK8055.new
@r.connect

@r.clear_all_digital

o = Octopus.new "/dev/ttyUSB0", 9600, 14
id_hash = {}

while true
id = o.read
if channel = id_hash[id]
@r.set_digital channel.to_i, false
# Clears the channel after certain delay.
Thread.new { sleep @off_delay; @r.set_digital channel.to_i, false }
else
print "Please enter a channel for this RFID tag '#{id}': "
id_hash[id] = gets.chomp
end
end

0 comments on commit f9672b4

Please sign in to comment.