Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: LED blinking Morse code from Raspberry Pi

by rje (Deacon)
on Sep 10, 2014 at 01:27 UTC ( [id://1100060] : note . print w/replies, xml ) Need Help??


in reply to LED blinking Morse code from Raspberry Pi

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.