+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: String <==> Morse Code

  1. #1
    Wire Amateur Jasongamer1 is on a distinguished road Jasongamer1's Avatar
    Join Date
    Aug 2009
    Location
    Nashville, Tennessee
    Posts
    67

    Cool String <==> Morse Code

    I know its stepping a bit back in time (just a bit), but I just thought it would be cool to send messages from player to player with morse code. Normally I would make the code myself, but this time I'm stepping aside to let my idea/challege spread to the community. Imagine PM'ing someone with morse code. It sounds cool, and you dont even have to understand what it says, as you would be able to simply convert it back into text.

    EDIT: This should be done in Expression2

  2. #2
    Wirezard

    Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,151

    Default Re: String <==> Morse Code

    . .- ... -.-- --..-- / .. / .-- --- ..- .-.. -.. / -- .- -.- . / .. - --..-- / -... ..- - / .. / -.. --- -. .----. - / .... .- ...- . / - .. -- .
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr


    Wire FPGA

  3. #3
    Drone Madman
    Lyinginbedmon has a spectacular aura about Lyinginbedmon has a spectacular aura about Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,651

    Default Re: String <==> Morse Code

    I recently made a string converter for transmitting data in signals after converting to binary, complete with sound accompaniment...this seems almost simple by comparison
    The Olympus Technologies drones, totally not SkyNet in Gmod form.
    Cronus: The Ultimate Drone, definitely SkyNet in Gmod form.
    The gBrain Project, the drone controls system that thinks it's better than you

    Need to learn how to make your own drones? Check out Drones with a Mad Scientist for my tutorials on how to do it.

  4. #4
    Wire Sofaking N00bDud3 has a spectacular aura about N00bDud3 has a spectacular aura about N00bDud3's Avatar
    Join Date
    Jul 2009
    Location
    Error: Unknown Location
    Posts
    970

    Default Re: String <==> Morse Code

    I may through together a code to do this when I wake up in the morning. I may even start working on it now, because I'm extremely bored.


  5. #5
    Spucatum Tauri Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    4,702

    Default Re: String <==> Morse Code

    I made these a year ago:

    Morse out:
    Use keyboard to enter a string. When pressing Enter it sends.
    Uses a wirelinked colorer to color a PHX plate Red and White. ( Lol )

    Morse in:
    Uses a ranger aimed at the plate to get the red color.
    It first get's the whole string until it receives the end signal.
    Then converts the morse code into a string.
    When the signal is interrupted it will show that with an _ .

    Code is old and unoptimized, but it works.

    e2 Code:
    1. @name Morse Out
    2. @inputs Color:wirelink Start KB:wirelink Reset
    3. @outputs Char Send String:string StringClk MorseString:string Keyboard
    4. @persist Morse:string LastKeyboard
    5.  
    6. # 13 32 97 122
    7. if (!Send) {
    8. interval(10)
    9. Keyboard=KB:readCell(1)
    10. if (Keyboard & Keyboard!=LastKeyboard & !Send) {
    11. if ((Keyboard>=97 & Keyboard<=122)|Keyboard==32) {
    12. String=String+toChar(Keyboard)
    13. }
    14. if (Keyboard==127 & String) {
    15. String=String:left(String:length()-1)
    16. }
    17. if (Keyboard==13) {
    18. Enter=1
    19. }
    20. StringClk=1
    21. LastKeyboard=Keyboard
    22. }
    23. }
    24. if (!Keyboard) {
    25. StringClk=0
    26. }
    27.  
    28. if (Send==2) {
    29. interval(100)
    30. if (Char<MorseString:length() & clk()) {
    31. Char++
    32. Color:setNumber("Fire",0)
    33. if (MorseString:index(Char)=="=") {
    34. Color:setNumber("R",254)
    35. }
    36. if (MorseString:index(Char)==".") {
    37. Color:setNumber("R",0)
    38. }
    39. Color:setNumber("Fire",1)
    40. }
    41. if (Char>=MorseString:length()) {
    42. Send=0
    43. String=""
    44. }
    45. }
    46.  
    47. if (Send==1) {
    48. interval(20)
    49. if (Char<String:length() & clk()) {
    50. Char++
    51. if (String:index(Char)=="a") {Morse="=.===..."}
    52. if (String:index(Char)=="b") {Morse="===.=.=.=..."}
    53. if (String:index(Char)=="c") {Morse="===.=.===.=..."}
    54. if (String:index(Char)=="d") {Morse="===.=.=..."}
    55. if (String:index(Char)=="e") {Morse="=..."}
    56. if (String:index(Char)=="f") {Morse="=.=.===.=..."}
    57. if (String:index(Char)=="g") {Morse="===.===.=..."}
    58. if (String:index(Char)=="h") {Morse="=.=.=.=..."}
    59. if (String:index(Char)=="i") {Morse="=.=..."}
    60. if (String:index(Char)=="j") {Morse="=.===.===.===..."}
    61. if (String:index(Char)=="k") {Morse="===.=.===..."}
    62. if (String:index(Char)=="l") {Morse="=.===.=.=..."}
    63. if (String:index(Char)=="m") {Morse="===.===..."}
    64. if (String:index(Char)=="n") {Morse="===.=..."}
    65. if (String:index(Char)=="o") {Morse="===.===.===..."}
    66. if (String:index(Char)=="p") {Morse="=.===.===.=..."}
    67. if (String:index(Char)=="q") {Morse="===.===.=.===..."}
    68. if (String:index(Char)=="r") {Morse="=.===.=..."}
    69. if (String:index(Char)=="s") {Morse="=.=.=..."}
    70. if (String:index(Char)=="t") {Morse="===..."}
    71. if (String:index(Char)=="u") {Morse="=.=.===..."}
    72. if (String:index(Char)=="v") {Morse="=.=.=.===..."}
    73. if (String:index(Char)=="w") {Morse="=.===.===..."}
    74. if (String:index(Char)=="x") {Morse="===.=.=.===..."}
    75. if (String:index(Char)=="y") {Morse="===.=.===.===..."}
    76. if (String:index(Char)=="z") {Morse="===.===.=.=..."}
    77. if (String:index(Char)==" ") {Morse="...."}
    78. MorseString=MorseString+Morse
    79. }
    80. if (Char==String:length()) {
    81. MorseString=MorseString+"=.=.=.===.=.===."
    82. Send=2
    83. Char=0
    84. interval(1000)
    85. }
    86. }
    87.  
    88. if ((~Start&Start)|Enter) {
    89. Color:setNumber("R",0)
    90. Color:setNumber("G",0)
    91. Color:setNumber("B",0)
    92. Color:setNumber("A",255)
    93. Send=1
    94. MorseString=""
    95. Enter=Char=0
    96. }
    97.  
    98. if (~Reset&Reset) {
    99. Color:setNumber("R",0)
    100. Color:setNumber("G",0)
    101. Color:setNumber("B",0)
    102. Color:setNumber("A",255)
    103. MorseString=String=""
    104. LastKeyboard=Keyboard=Enter=Char=Send=0
    105. }

    e2 Code:
    1. @name Morse In
    2. @inputs Color Reset
    3. @outputs Receiving PrintString:string CharLength StringClk Morse:string Fail Printing
    4. @persist
    5.  
    6. if (Receiving&clk()) {
    7. interval(100)
    8. if (Color==254) {
    9. Morse=Morse+"="
    10. }
    11. if (!Color) {
    12. Morse=Morse+"."
    13. }
    14. if (Color & Color!=254) {
    15. Morse=Morse+"X"
    16. }
    17. if (Morse:length()>=15) {
    18. if (Morse:right(15)=="=.=.=.===.=.==="|Morse:right(10)=="..........") {
    19. Receiving=0
    20. Printing=1
    21. }
    22. }
    23. }
    24.  
    25. if (~Reset&Reset) {
    26. Morse=""
    27. Receiving=0
    28. }
    29.  
    30. if (~Color & Color==254 & !Receiving) {
    31. interval(50)
    32. Receiving=1
    33. Morse=""
    34. PrintString=""
    35. Printing=Fail=StringClk=0
    36. }
    37.  
    38. if (Printing) {
    39. interval(10)
    40. if (clk()) {
    41. if (Morse:left( 8)=="=.===..." & !CharLength) {Char="A" CharLength=8}
    42. elseif (Morse:left(12)=="===.=.=.=..." & !CharLength) {Char="B" CharLength=12}
    43. elseif (Morse:left(14)=="===.=.===.=..." & !CharLength) {Char="C" CharLength=14}
    44. elseif (Morse:left(10)=="===.=.=..." & !CharLength) {Char="D" CharLength=10}
    45. elseif (Morse:left( 4)=="=..." & !CharLength) {Char="E" CharLength=4}
    46. elseif (Morse:left(12)=="=.=.===.=..." & !CharLength) {Char="F" CharLength=12}
    47. elseif (Morse:left(12)=="===.===.=..." & !CharLength) {Char="G" CharLength=12}
    48. elseif (Morse:left(10)=="=.=.=.=..." & !CharLength) {Char="H" CharLength=10}
    49. elseif (Morse:left( 6)=="=.=..." & !CharLength) {Char="I" CharLength=6}
    50. elseif (Morse:left(16)=="=.===.===.===..." & !CharLength) {Char="J" CharLength=16}
    51. elseif (Morse:left(12)=="===.=.===..." & !CharLength) {Char="K" CharLength=12}
    52. elseif (Morse:left(12)=="=.===.=.=..." & !CharLength) {Char="L" CharLength=12}
    53. elseif (Morse:left(10)=="===.===..." & !CharLength) {Char="M" CharLength=10}
    54. elseif (Morse:left( 8)=="===.=..." & !CharLength) {Char="N" CharLength=8}
    55. elseif (Morse:left(14)=="===.===.===..." & !CharLength) {Char="O" CharLength=14}
    56. elseif (Morse:left(14)=="=.===.===.=..." & !CharLength) {Char="P" CharLength=14}
    57. elseif (Morse:left(16)=="===.===.=.===..." & !CharLength) {Char="Q" CharLength=16}
    58. elseif (Morse:left(10)=="=.===.=..." & !CharLength) {Char="R" CharLength=10}
    59. elseif (Morse:left( 8)=="=.=.=..." & !CharLength) {Char="S" CharLength=8}
    60. elseif (Morse:left( 6)=="===..." & !CharLength) {Char="T" CharLength=6}
    61. elseif (Morse:left(10)=="=.=.===..." & !CharLength) {Char="U" CharLength=10}
    62. elseif (Morse:left(12)=="=.=.=.===..." & !CharLength) {Char="V" CharLength=12}
    63. elseif (Morse:left(12)=="=.===.===..." & !CharLength) {Char="W" CharLength=12}
    64. elseif (Morse:left(14)=="===.=.=.===..." & !CharLength) {Char="X" CharLength=14}
    65. elseif (Morse:left(16)=="===.=.===.===..." & !CharLength) {Char="Y" CharLength=16}
    66. elseif (Morse:left(14)=="===.===.=.=..." & !CharLength) {Char="Z" CharLength=14}
    67. elseif (Morse:left( 4)=="...." & !CharLength) {Char=" " CharLength=4}
    68. elseif (Morse:left(15)=="=.=.=.===.=.===" & !CharLength) {StringClk=1 Printing=0 CharLength=15}
    69. else {
    70. if (Morse:left(1)=="X" & !Fail) {
    71. Char="_"
    72. Fail=1
    73. }
    74. Morse=Morse=Morse:right(Morse:length()-1)
    75. }
    76. if (Char) {
    77. PrintString=PrintString+Char
    78. }
    79. Morse=Morse:right(Morse:length()-CharLength)
    80. if (CharLength) {
    81. Fail=0
    82. }
    83. CharLength=0 Char=""
    84. if (!Morse) {
    85. Printing=0
    86. PrintClk=1
    87. }
    88. }
    89. }
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

  6. #6
    Wirezard

    Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,151

    Default Re: String <==> Morse Code

    Quote Originally Posted by Bull View Post
    I made these a year ago:

    Morse out:
    Use keyboard to enter a string. When pressing Enter it sends.
    Uses a wirelinked colorer to color a PHX plate Red and White. ( Lol )

    Morse in:
    Uses a ranger aimed at the plate to get the red color.
    It first get's the whole string until it receives the end signal.
    Then converts the morse code into a string.
    When the signal is interrupted it will show that with an _ .

    Code is old and unoptimized, but it works.

    e2 Code:
    1. #Code

    e2 Code:
    1. #Code
    Eh... How do you get "=.===..." equal to "a" in morse? It should be ".=". Same with all the other letters... "e" is ".", not "=...".
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr


    Wire FPGA

  7. #7
    Spucatum Tauri Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    4,702

    Default Re: String <==> Morse Code

    You don't know how to read my code.
    In morse an dash is equal to 3 times a dot.

    I simply coded a dash as ===, a dot as = and silence as a .

    A:
    =.===... Dot - Silence - Dash - Silence between 2 letters
    B:
    =... Dot - Silence between 2 letters

    Quote Originally Posted by wikipedia
    1. short mark, dot or 'dit' (?) — 1
    2. longer mark, dash or 'dah' (–) — 111
    3. intra-character gap (between the dots and dashes within a character) — 0
    4. short gap (between letters) — 000
    5. medium gap (between words) — 0000000
    Replace the 0's by . , 1's by = and you end up at my code.
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

  8. #8
    Wirezard

    Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,151

    Default Re: String <==> Morse Code

    Ah, ok. Was trying to read your code, but it didn't make any sense :P
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr


    Wire FPGA

  9. #9
    Spucatum Tauri Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    4,702

    Default Re: String <==> Morse Code

    Well, I didn't make it easier by mixing up the notation.
    I made that code as a own one hour thing , I never thought about posting it.

    (Maybe I did somewhere, can't remember. )
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

  10. #10
    Wire Amateur Jasongamer1 is on a distinguished road Jasongamer1's Avatar
    Join Date
    Aug 2009
    Location
    Nashville, Tennessee
    Posts
    67

    Default Re: String <==> Morse Code

    I'm suprised as to how quickly you guys replied to this. anyway, why are you using "=" rather than "-"?

    EDIT: forget I said ^ , it was completely irrelevant to the challenge
    Last edited by Jasongamer1; 02-09-2010 at 12:31 PM.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots