logo
  
A morse decoder for arduino
An algorithm for decoding Morse code with arduino, some inspiration from this article
 
From wikipedia:
The perfect morse code needs:
  1. short mark, dot or 'dit' (·) — 'dot duration' is one unit long
  2. longer mark, dash or 'dah' (–) — three units long
  3. inter-element gap between the dots and dashes within a character — one dot duration or one unit long
  4. short gap (between letters) — three units long
  5. medium gap (between words) — seven units long

The real morse code has a dot:dash ratio of 2.5:1 to 3.5:1

Firstly, we need to determine this ratio:
If the inter-element gap length is denoted as Tm and dot as Td:
Use the first ten time lengths to calculate Tm and Td
 
High Level Time=H_TIME [ie not pressing]
Low Level Time=L_TIME [ie key pressing]
blank a dot/dash array
R=H_TIME[n]/Tm
If (R with 0.5 and 1.5) {
      S=L_TIME[n-1]/Td
      if (S within 2.5 and 3.5) {
             dash
      } else {
             dot
      }  
advance to next element in dot/dash array


} else  if R (within 2.5-3.5) {
           we have a letter space hence decode array
}
 
 
Another algorithm obtained from here can be summarised in this diagram