Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
I've got an update. Today I got a set of little patch cables in the mail and hooked up an old single-digit LED display to seven of the GPIO ports. I then added these subroutines to my library:
sub bar { my @bar = @_; for my $pin (@pins) { Device::BCM2835::gpio_write( $pin, 0 ); } Device::BCM2835::delay( 40 ); for my $pin (@pins) { my $val = shift @bar; Device::BCM2835::gpio_write( $pin, 1 ) if $val == 1; } Device::BCM2835::delay( 240 ); } sub bilanidin { while ($_ = lc shift) { print "$_\n"; bar( qw/1 0 1 0 1 0 1 1/ ) if /a/; bar( qw/0 0 0 0 0 1 0 1/ ) if /b/; bar( qw/1 0 1 1 0 1 1 1/ ) if /ch/; bar( qw/1 0 0 0 1 1 0 0/ ) if /d/; bar( qw/1 0 0 1 0 1 1 0/ ) if /e/; bar( qw/1 0 0 0 1 0 0 1/ ) if /g/; bar( qw/0 0 0 1 0 1 1 0/ ) if /[ijy]/; bar( qw/1 0 0 1 1 0 1 0/ ) if /[kq]/; bar( qw/0 0 1 1 1 1 0 0/ ) if /l/; bar( qw/0 0 1 1 0 0 1/ ) if /m/; bar( qw/0 0 1 1 1 0 0 1/ ) if /n/; bar( qw/1 0 0 0 1 1 1 1/ ) if /o/; bar( qw/0 0 1 1 0 1 1 0/ ) if /p/; bar( qw/0 0 1 0 0 0 1 1/ ) if /r/; bar( qw/0 0 1 1 1 0 1 0/ ) if /s/; bar( qw/0 0 1 0 1 0 1 1/ ) if /t/; bar( qw/0 0 1 0 0 0 1 0/ ) if /[huvw]/; bar( qw/1 0 1 1 1 0 1 0/ ) if /x/; bar( qw/0 0 0 1 0 0 1 1/ ) if /z/; } Device::BCM2835::delay( 400 ); bar( qw/0 0 0 0 0 0 0 0/ ); }
"Bilanidin" is a font designed by Marc Miller for the Traveller pencil-and-paper RPG. I adapted it to the display as closely as I could.

Now my little server can talk to me in bilanidin letters as well as Morse code. This is a lot of fun.


In reply to Re: LED blinking Morse code from Raspberry Pi by rje
in thread LED blinking Morse code from Raspberry Pi by rje

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.