Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest for a simple function to generate morse code instead of writing interation again and again. It coulde something like this.</p> <p>GenerateMorseCode(char MorseArray[], int len);</p> <p>You can fill MorseArray with some identifier for dit and dah: May be you can use dot (.) and hipen(-). So for 3 dit , 3dah and 3 dit. Your array would be </p> <pre><code>...---... </code></pre> <p>with length of array as 9. Now inside GenerateMorseCode function all you need to do to parse the MorseArray. You can use simple switch case something like this</p> <pre><code>GenerateMorseCode(char MorseArray[], int len) { for(int i =0i&lt;len;i++) { switch(MorseArray[i]) { case '.': //Your led logic in case of dot break; case '-': //Your led logic in case of dah break; } } } </code></pre> <p>Further more you can wrap this function inside another function which keep calling GenerateMorseCode function as per specified loops. To generate MorseArray you can create a map of char array with Morse code. You can keep adding new enum and update corresponding Morsemap. Something like this</p> <pre><code>#define MAX_ELEM 12 enum MorseCode { A_M = 0, B_M, C_M, SOS_M }; typedef struct MorseMap { char array[MAX_ELEM]; }; MorseMap mm[3] = {{'.','-','\0'},{'-','.','.','.','\0'},{'-','.','-','.','\0'} }; </code></pre> <p>Also there is no need to length now, it can be calculated from char array. To access any Morse code use mm[A_M] or mm[SOS_M]</p> <pre><code>GenerateMorseCode(char arr[]) { int len = strlen(arry); //Above for loop and switch case case } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload