Morse code not printing

I'm using the library EasyMorse and I can get the Morse code to print out in lines and dashes but i cant get the command morse.getChar() to work it doesn't give an error message but it just doesn't work

This is the bit not working:

'''
if(timer.read() >= 200){
Serial.print(morse.getChar());
morse.clear();
}
'''

morse.getChar() could return zero ('\0').
Then the morse.clear() erases anything that was in the buffer.

Edit: It appears the morse.getChar() function returns zero if nothing in the buffer. Just keep checking until not zero. Don't morse.clear() unless in setup().

Did you Serial.begin(115200);?

yes, i used Serial.begin(9600);

I would try this:

if(timer.read() >= 200){
   char ch = morse.getChar();
   if(ch !=0) {
      Serial.print(ch);
   }
}

i just looked back on my code and it turns out that in a previous if statement instead of == for a bool i just put =. lol

This is why you agreed to post your code, drawing and description of operation, to gain access to the forum... lol.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.