Ok, I have not been diligent in producing some software. Most of the algorithms that I have seen to do this job are rather slow. I have defined a MAX_LETTERS as a constant of 10 which will give me generous room for my ID Code. Since I like to modular my code I will need to write a function void sendTone( char 'letter' );

BTW this device (Arduino) is a listener con the CAN bus.

 

MorseCode.hMorseCode.c

// morseCode d==dot D==Dash

//morseCode[value][string]

 

char morseCode[26][MAX_LETTERS] = {

"dD",   "Dddd", "DdDd", "Ddd,

"d",    "ddDd", "DDd",  "dddd",

"dd",   "dDDD", "DdD",  "dDdd",

"DD",   "Dd",   "DDD",  "dDDd",

"DDdD", "dDd",  "ddd",  "D",

"ddD",  "dddD", "dDD",  "DddD",

"DdDD", "DDdd"};

 

//units

const int TIME_UNIT = 250ms

const int DOT = TIME_UNIT;

const int DASH = 3 * TIME_UNIT;

const int C_SPACE = 2 * TIME_UNIT;

const int W_SPACE = 5 * TIME_UNIT;

const int LETTER_SPACE =

const int MAX_LETTERS = 10;

 

// Commands:

const int sendDot = 1;

const int sendDash = 2;

const int sendC_space = 3;

const int sendL_space = 4;

const int sendW_space = 5;

 

 

// pre-defines

getWord( char *name );

#include <stdio.h>

#include <stdlib.h>

#include <morseCode.h>

int main() {

getWord( char *name ){

    char letter;

    for( int count = 0; count <= MAX_LETTERS; count++)

        if( letter = name[count] != '\n') {

            int offset = 0x40 - letter;

            for(int v = 0; code = morseCode[offset][v] != '\n'; v++) {

                   If ( code  == 'D' || code == 'd' )  {  

                          sendMorse(  L, code ); }

                   elseif (code == {

                           sendMorse( S, code ); }

}              

 

return EXIT_SUCCESS;

}

Notes: the char array morseCode is an array of strings which are automatically terminated with a '\n'

void sendTone( char tone ) {

//  To be done later;

}

// please ignore the sendTone and sendSpace They have been replaced with a new function

int sendMorse( int command char*  Sound ) {

       switch ( command } {

            case sendDot: {

                   // generate Sound

                   break; }

            case sendDash: {

                   // generate Dot

                   break; }

            case sendC_space: {

                    // generate Sound

                   break; }

            case sendL_Sound: {

                   // generate Sound

                  break; }

            case sendW_space: {

                    // generate Sound

                   break; }

            defualt; { }}}

 

void sendSpace( int space ) {

// to be done later;

}

 

 

 

/