So you need two barcodes to sit side by side. '0' and '1'. You can create them with this code:

#!/usr/bin/perl use strict; use warnings; use GD::Barcode::Code39; MakeBar('0'); MakeBar('1'); sub MakeBar { my $txt = shift; my $oGdBar = GD::Barcode::Code39->new("*$txt*"); die $GD::Barcode::Code39::errStr unless($oGdBar); open(IMG, ">", "$txt.png") or die $!; binmode(IMG); print IMG $oGdBar->plot(NoText=>1, Height => 40)->png; close(IMG); }

Then print and affix them to your door. I haven't tested the following code because I have hacked my cuecat to decode the scans but you could use something like this:

#!/usr/bin/perl use strict; use warnings; use Barcode::Cuecat; # seperate counters for open and closed my $open = 0; my $close = 0; my $door; my $bc = new Barcode::Cuecat(); while (<>) { $bc->scan($_); $door .= $bc->code(); if (length $door == 2) { $open++ if ($door eq "01"); $close++ if ($door eq "10"); $door = ""; # we will assume the door started out closed my $state = "closed"; $state = "open" if ($open > $closed); print "Opened: $open times\n"; print "Closed: $closed times\n"; print "Current state: $state\n"; # write to disk } }


In reply to Re: The Door Server by Mr. Muskrat
in thread The Door Server by beretboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.