Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- $gpio=24;
- $delay=0.25; #Delay of send speed
- $pause=1*$delay;
- $dot_pause=1*$delay;
- $dash_pause=3*$delay;
- $character_pause=3*$delay;
- $word_pause=7*$delay;
- print "\n [+]====================================[+]";
- print "\n | Send Morse Code On LED Wtih GPIO | ";
- print "\n | | ";
- print "\n | GPIO Pin -> $gpio "; if ($gpio<9) { print " "; } print "| ";
- print "\n | Created By : AssazziN | ";
- print "\n | Version : 1 [03/17/2013] | ";
- #print "\n | http://comfeedom.blogspot.com | ";
- print "\n | | ";
- print "\n [+]====================================[+] ";
- print "\n\n";
- print " Message >> ";
- chomp($text=<STDIN>);
- $original_text=$text;
- @original_text=split //,$original_text;
- $text=~s/ /\//ig;
- $text=~s/\./.-.-.- /ig;
- $text=~s/,/--..-- /ig;
- $text=~s/\?/..-.. /ig;
- $text=~s/a/.- /ig;
- $text=~s/b/.--- /ig;
- $text=~s/c/-.-. /ig;
- $text=~s/d/-.. /ig;
- $text=~s/e/. /ig;
- $text=~s/f/..-. /ig;
- $text=~s/g/--. /ig;
- $text=~s/h/.... /ig;
- $text=~s/i/.. /ig;
- $text=~s/j/.--- /ig;
- $text=~s/k/-.- /ig;
- $text=~s/l/.-.. /ig;
- $text=~s/m/-- /ig;
- $text=~s/n/-. /ig;
- $text=~s/o/--- /ig;
- $text=~s/p/.--. /ig;
- $text=~s/q/--.- /ig;
- $text=~s/r/.-. /ig;
- $text=~s/s/... /ig;
- $text=~s/t/- /ig;
- $text=~s/u/..- /ig;
- $text=~s/v/...- /ig;
- $text=~s/w/.-- /ig;
- $text=~s/x/-..- /ig;
- $text=~s/y/-.-- /ig;
- $text=~s/z/--.. /ig;
- $text=~s/1/.---- /ig;
- $text=~s/2/..--- /ig;
- $text=~s/3/...-- /ig;
- $text=~s/4/....- /ig;
- $text=~s/5/..... /ig;
- $text=~s/6/-.... /ig;
- $text=~s/7/--... /ig;
- $text=~s/8/---.. /ig;
- $text=~s/9/----. /ig;
- $text=~s/0/----- /ig;
- print " Sending >> $original_text[0]";
- $count_text=1;
- foreach (split //,$text) {
- if ($_ eq '.') {
- system("echo \"0\" > /sys/class/gpio/gpio$gpio/value");
- select undef,undef,undef,$pause;
- system("echo \"1\" > /sys/class/gpio/gpio$gpio/value");
- select undef,undef,undef,$dot_pause;
- }
- elsif ($_ eq '-') {
- system("echo \"0\" > /sys/class/gpio/gpio$gpio/value");
- select undef,undef,undef,$pause;
- system("echo \"1\" > /sys/class/gpio/gpio$gpio/value");
- select undef,undef,undef,$dash_pause;
- }
- elsif ($_ eq ' ') {
- system("echo \"0\" > /sys/class/gpio/gpio$gpio/value");
- select undef,undef,undef,$character_pause;
- print "$original_text[$count_text]";
- $count_text++;
- }
- elsif ($_ eq '/') {
- system("echo \"0\" > /sys/class/gpio/gpio$gpio/value");
- select undef,undef,undef,$word_pause;
- print "$original_text[$count_text]";
- $count_text++;
- }
- else { print "\nERROR: $_\n"; exit; }
- }
- #http://comfreedom.blogspot.com/2013/03/raspberry-pi-morse.html
- print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement