Am trying to develop a system to use alpha numeric keyboard to enter a msg and convert it to corresponding morse code using an arduino.
I downloaded a morse code library, seeing the library and the SOS example i have tried to develop a library of morse code for each alphabet.
also i wrote a sketch similar to the SOS example.
but while compiling am getting the an error.
The error msg is ----
" temp.ino: In function 'void loop()':
temp:12: error: 'morsealpha' was not declared in this scope"
The downloaded library, the alphabet library and my sketch is attached.
Somebody please point out my mistakes and help me correct them.
Where does the morsealpha object get instantiated?
Also, the normal relationship between dits and dahs is 1:3, but you're doing 1:4. What if I want to send code at higher or lower words/minute? You need to add a variable that is passed to delay() that represents the number of milliseconds you want to delay for a dot or dash. You could do something like this near the top of your temp program:
Now if you change DITDELAY, the speed changes for the methods automatically. There are much more efficient ways to code the Morse alphabet than this way, too.
Its tragic really that the official examples at the Arduino site include a Morse blinker
example with the wrong ratio between dot and dash length... All it takes is a quick
visit to wikipedia or wherever to check. Ho hum...
econjack:
Where does the morsealpha object get instantiated?
Also, the normal relationship between dits and dahs is 1:3, but you're doing 1:4. What if I want to send code at higher or lower words/minute? You need to add a variable that is passed to delay() that represents the number of milliseconds you want to delay for a dot or dash. You could do something like this near the top of your temp program:
#define DITDELAY 250
#define DAHDELAY (DITDELAY * 3)
and then adjust your *dot()* and *dah()* methods accordingly to use the new values:
Now if you change DITDELAY, the speed changes for the methods automatically. There are much more efficient ways to code the Morse alphabet than this way, too.
I didn't realize the mistake of the ration being 1:4 instead of 1:3..
useing the #define in temp.ino gives a long list of errors.
i have used the code u suggested in morsealpha.cpp and its working, but will i be able to change the value of DITDELAY from the program temp.ino??
useing the #define in temp.ino gives a long list of errors
So you got it wrong, but you didn't post your changes or the error messages, so there's not a lot we can do to help.
On defining DITDELAY & DAHDELAY in Morse.cpp, am not able to vary the values of DITDELAY from temp.ino.
Also on defining the same in temp.ino as advised by econjack
The error msg is ----
C:\Program Files (x86)\Arduino\libraries\Morse\Morse.cpp: In member function 'void Morse::dot()':
C:\Program Files (x86)\Arduino\libraries\Morse\Morse.cpp:33: error: 'DITDELAY' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Morse\Morse.cpp: In member function 'void Morse::dash()':
C:\Program Files (x86)\Arduino\libraries\Morse\Morse.cpp:49: error: 'DAHDELAY' was not declared in this scope
C/C++ is case-sensitive, and you haven't declared an instance of MorseAlpha called "morsealpha"
Edit: I can't see a constructor for MorseAlpha
I am new to C++ programming and so i am still sturggling with the declaration and required constructor.
everything i am trying is based on what i could figure out from given examples.
I would be grateful to you if you could help on how i should do the declaration and what my constructor should look like.
Rather than trying to figure things out from the examples, it will save you time and frustration in the longer run by buying or downloading a competent textbook and reading it.