Permalink
Browse files

Added demo for k8055 usb interface board

  • Loading branch information...
ndbroadbent committed Jul 1, 2010
1 parent 48b5b4e commit f9672b4c77db47bd114508ad6752bfa0bcab6940
Showing with 27 additions and 0 deletions.
  1. +27 −0 octopus_k8055.rb
View
@@ -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.