

To make a gap apply a pull-down resistor.
#Wb7fhc morse decoder series
Otherwise you need to create artificial memory cells and artificial binary words.Įach character (dots and dashes) can be stored as a series of diode-resistor pull up networks. The job is easier with a computer of course. It successfully translated beeps into English text onscreen. It still decoded OK with the sender having a dot length of 20 ms (five times as fast) so I think that shows the general idea is OK.I developed my own morse decoder years ago for my Commodore computers. GYRE AND GIMBLE IN THE WABE ALL MIMSY WERE THE BOROGOVES AND THE MOME RATHS OUTGRABE BEWARE THE JABBERWOCK MY SON THEĪs you can see, it got the dot width right except for one millisecond. It's not the most efficient code, but it works.

That gets turned into a string, and a string compare deduces which letter/number it is. Then, based on that, it detects on-sequences and stores them in an array. Hopefully it gets a dot in that first string.
#Wb7fhc morse decoder generator
(millis () - lastPulse) >= (dotLength * 2) &Ĭonnect pin 13 of the generator Uno (also visible on the LED) to pin 2 of the decoder Uno (where it can trigger an interrupt).įirst the decoder reads a series of dots/dashes to try to work out which is a dot. If (pinState = HIGH & width >= (wordLength - FUZZ_FACTOR)) If (c >= 'A' & c = '0' & c = (dashLength - FUZZ_FACTOR)) "The jaws that bite the claws that catch "
#Wb7fhc morse decoder code
First we need some test data, so I adapted my earlier morse code generator program to output a fixed sequence: // Morse code generatorĬonst unsigned long dotLength = 100 // mSĬonst unsigned long dashLength = dotLength * 3 Ĭonst unsigned long wordLength = dashLength * 2 Ĭhar buf = "Twas brillig and the slithy toves " So therefore an interval of 80 ms to 120 ms could be considered a dot, an interval of 280 to 320 ms a dash, and so on (depending on the exact rate at which the morse is transmitted), which you can deduce, by measuring gaps. Of course you wouldn't test for exactly equal to 100, but give-or-take 10 or 20%. You wouldn't need a very large array, because once you get a gap of 2 x the dot length you can assume you are 2/3 through a dash gap, and therefore at the end of the current letter, which you can now decode. Now you can work out dots and dashes, since there is quite a big leeway. So the first thing you could deduce is that the gaps will either be a dot length, or if a gap is long (3 times as long) you have a letter gap, and very long (6 times as long) is a word gap. And there is a dot length between dots and dashes. As I recall, a dash is 3 x the dot length, the gap between letters is a dash length, and word gap is 2 x the dash length.

high to low, low to high), measure the difference, and put them into an array. For the life of me I can't understand why this is - I could understand if it was equal to or greater than 100ms. However, if I changed it to 50ms for example the decoding seems to break. The delay in listen_morse (60ms) is designed to offset the read a certain way through each 100ms time unit.

It still needs a bit of work but seems to fundamentally work except for one strange issue. Return total_light_val/3 //return average base light level Total_light_val = total_light_val + analogRead (pin) If (BASE_LIGHT_LEVEL - analogRead(pin) > LIGHT_SENSITIVITY) If (i + 3 >= strlen (raw_input)) //end of morse wordīool get_light_level (byte pin,int BASE_LIGHT_LEVEL) Memset (morse,'\0',10) //reset at the beginning of each callįor (int i=0 i = strlen (raw_input)) //end of morse word If (strcmp (buffer,"0000000") = 0) //return spaceĬhar ascii = morse_to_ascii(raw_to_morse(buffer)) Įlse if (strstr(buffer,"0000") & strlen(strstr(buffer,"0000")) = 4 ) // must be spaceĬhar* raw_to_morse (const char* raw_input) If (get_light_level(pin,BASE_LIGHT_LEVEL))ĭelay (60) // read 60ms into each time unitīuffer = get_light_level(pin,BASE_LIGHT_LEVEL) + 48 I thought it may be fun to write a morse decoder for the arduino (it uses a ldr but thats not particular important).īASE_LIGHT_LEVEL = calibrate_sensor(pin)
