Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added demo for k8055 usb interface board

  • Loading branch information...
commit f9672b4c77db47bd114508ad6752bfa0bcab6940 1 parent 48b5b4e
@ndbroadbent authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 octopus_k8055.rb
View
27 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
+
Please sign in to comment.
Something went wrong with that request. Please try again.