Help running old .cpp code

I am trying to do an old project I never finished years ago. The code I had found is here:
https://code.google.com/archive/p/morse-endecoder/downloads

I cant for the life of me get it to compile. I am downloading the .tar nd putting the .cpp and .h into a folder called MorseEnDecoder inside my arduino libraries folder.

im then changing the .cpp to .ino, it tells me to put it inside a folder, so I let it, then drag the .h into the folder. run the .ino........ and try to compile it.

ive modified the .h file with the following

//#include <WProgram.h>
#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
  #else
  #include "WProgram.h"
  #endif
#include <Wire.h>
C:\Users\wd\AppData\Local\Temp\ccWxtoue.ltrans0.ltrans.o: In function `main':

C:\Users\wd\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.23\cores\arduino/main.cpp:43: undefined reference to `setup'

C:\Users\wd\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.23\cores\arduino/main.cpp:46: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

and get the following errors. Can anybody help ?????

Please copy that code, format it in the IDE and post it here using code tags, </>.

It's annoying digging, following links and downloading code from the Internet plenty of times. Who cleans up my computer from all those downloads?

Put the files into the same folder (remember Arduino's rules about folder naming.)
Restart ArduinoIDE and open the main .ino file.

*.cpp and *.h files will appear in IDE tabs.
Make certain that the main sketch has a line with
#include "./Morse_EnDecoder.h"

The tab with the .cpp file must also have the same include as above!

Ray

PS: here is an old Morse Code project I wrote:
Magic Morse

There are FOUR versions there. I assume you are using the latest (BETA) version?
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/morse-endecoder/Morse_EnDecoder_2012.11.25.tar.gz

  1. Download it.
  2. Unpack it.
  3. Drag it to your 'libraries' directory.
  4. Re-start the Arduino IDE.
  5. Select File->Examples->Morse_EnDecoder->Morse_EnDecoder_demo
  6. Compile it.

Error messages:

MorseEnDecoder.cpp:75:19: error: variable 'morseTable' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 char morseTable[] PROGMEM =
                   ^

That's a newer requirement. Edit "MorseEnDecoder.cpp" line 75 to add the required 'const' keyword at the beginning.

Now it will compile with only a few warnings.

John wasser. You helped me many a time ten years ago on several projects. I remember the name well.

I will try your advice tonight when the kids are in bed.

Thanks in advance.

That magic Morse looks of interest. Can it encode text and decode Morse ?

I may look at that in parallel. After all I'm after the best result possible.

+1
I simply love optimism in a forum response :slightly_smiling_face:

i almost cracked it last night , almost, i had changed char to const, not added const to the line.
its compiled now, i cant wait to test it :slight_smile:

it has compiled and uploaded, and for now working as expected. Thanks everyone.!!

I have this running now, but it is quite dependant on volume when listening for morse via the microphone..... too loud and it gets it wrong, too quiet and it doesnt get it right. lol
when just right it does however work.

is yours any better at decoding from a mic?

No, it was rather finicky.

Ray

Thanks! I kind of randomly found this thread a little while ago, I wouldn't have known about this otherwise.

I updated the latest beta version (of Nov 25, 2012) I had on that old google code page with your fix. It's now on github (as you can't change what's on the google code page) instead.

If anyone want an older version (without the virtual functions), for now you have to download from the older google code page and make the change you describe (adding "const" at beginning of the line with the PROGMEM array).

It's not a big change anyway. I just figured I could / should update at least one version. Even if it's only ever-so slightly (it could still use some improvements that I never implemented...).

Btw I haven't been active with Arduino for years, basically. The example sketches compile in Arduino IDE 1.8.13. That's all I can say really. Otherwise, no guarantee it'll work as intended and all that.

EDIT: to reflect change in github description