Public projects 1

Morse Encoder & Displayer

Project showcase by rajdakin

  • 2,761 views
  • 4 comments
  • 13 respects

Toolbox 3


Respected projects 0

 rajdakin hasn't respected any projects yet.

Comments 1

  • Morse Encoder & Displayer 8 months ago

    Yeah, that can work, but here I think it may over-complicate the program. In morse, there is only up to 4 "characters" per ASCII letter, so I don't need to decrease the character size.
    But if there is an other language that uses only two characters and that is a bit more expensive when converting from ASCII to this new language (or it could be that morse actually has a translation for puctuation that uses up to 7 characters, but I'm not aware of that), this method can totally be worth it.
    It may be more optimized and clearer though to use the whole word, to shift to the right and to actually have a 1 when it is longer (dash), like so:
    C
    #define AtoM_START 32
    #define AtoM_LENGTH 59
    #define AtoM_DEFAULT 0b00000001
    PROGMEM const uint8_t AtoM[AtoM_LENGTH] = {
    0b00000001, // ASCII 20 [space]
    ...
    0b00000101, // ASCII 41 A
    0b00011110, // ASCII 42 B
    ...
    0b00011100, // ASCII 5A Z
    };

    And then inside a function:
    ```C
    char ascii = Serial.read();

    uint8_t morse;
    if ((ascii < AtoM_START) || (ascii > AtoM_START + AtoM_LENGTH)) {
    morse = AtoM_DEFAULT;
    } else {
    uint8_t morse = AtoM[ascii - AtoM_START];
    }
    while (morse > 1) {
    if (morse & 1) {
    dash();
    } else {
    dot();
    }
    morse >>= 1;
    }
    ```

Add projectSign up / Login