conbination of two codes ! (4x4 keypad to 16x2 lcd texter), morse EnDecoder !

well i thing that it has to do with some kind of timer.

those are the conclusion i came up so far.

first of all this is the code i use ( it is the last function is the texter code )

void outputserial(){ //output message and display remaining characters to serial console
morseInput.setspeed(13);
morseOutput.setspeed(13);
lastTransmissionTime = (long)millis();
if (morseOutput.available()){
for (int i=0; i<(positionintypedtext); i++){
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);
// Variables dealing with formatting the output somewhat
// by inserting CR's (carriage returns)
Serial.println();
Serial.print(i);
Serial.print(')' );
Serial.print(lastTransmissionTime);
Serial.print(' ');
currentTime = (long)millis();
Serial.print(currentTime);
Serial.print(' ');
// Needs to call these once per loop
// SEND MORSE (OUTPUT)
// Encode and send text received from the serial port (serial monitor)
// Get character from serial and send as Morse code
char sendMorse = typedtext[i];
morseOutput.write(sendMorse);
Serial.print(' ');
Serial.print(sendMorse);
// Not strictly needed, but used to get morseSignalString before it is destroyed
// (E.g. for morse training purposes)
morseOutput.encode();
// Also write sent character + Morse code to serial port/monitor
Serial.write(' ');
Serial.write(sendMorse);
Serial.write(morseOutput.morseSignalString);
}
// RECEIVE MORSE (INPUT)
// If a character is decoded from the input, write it to serial port
}
delay(preventholddelay); //delay a little to prevent continuous cycling
}

and this is what i take as results in serial window ( for a random text i entered ) :
0)6413 6413 E E.
1)6413 6414 N N-.
2)6413 6415 J J.—
3)6413 6418 P P.–.
4)6413 6440 G G–.
5)6413 6463 A A.-
6)6413 6483 P P.–.
7)6413 6506 J J.—
8)6413 6530 D D-..
9)6413 6551 J J.—
10)6413 6575 T T-
11)6413 6596 M M–
12)6413 6618 D D-..
13)6413 6640 P P.–.
14)6413 6665 M M–
15)6413 6686 A A.-
16)6413 6708 J J.—
17)6413 6732 T T-
18)6413 6753 J J.—
19)6413 6776 D D-..
20)6413 6800 T T-
21)6413 6820 M M–
22)6413 6842 D D-..
23)6413 6865 T T-
24)6413 6886 W W.–
25)6413 6908 M M–
26)6413 6931 J J.—
27)6413 6955 T T-

first of all, i see that there is a ~ 22 milisecconds deference between each time it passes through the for loop, except the three first ones that passes in just 1 millisecond.

if (morseOutput.available()
this works, while if this didn’t work it wouldn’t go through the for loop and i wouldn’t get the print outs i have sent you above. :smiley: !
i changed pinout to 2, just iin case and it was messing with the pin 13 and the outpouts to the Serial window. nop that wasn’t. :smiley: !
i am preaty sure that the communication with the library is really ok while with out it
Serial.write(morseOutput.morseSignalString); couldn’t get the print outs with the char and the morse code right next. :smiley: !
but if the library connection is ok,
morseOutput.write(sendMorse);
witch everytime it passes through the for loop is the correct character, SO EVEN THIS WORKS :smiley: !
morseOutput.encode();
when we get to this guy, ( oh my head is a mess right now, and i am still loughing ) it seems like it works for some milliseconts.
my grandma used to say ” it is at a corner, and it is smilling at you ” everytime i was looking for something.
it is really close but i can not figure out why it is not working.
i don’t want to mess with the libraries. i am preaty sure that the libraries are ok.
if you have any sudgestions . any of some sort ….. more than welcome.

apologies for the all caps but the forum is acting up again.

doing things on time is the first lesson because it is the one that lets you get rid of the delays that slow everything down badly and stop real time, real world code from working.

just because one thing needs to wait, without using time you have to make ==everything== wait. that is called "blocking".

the timer used is the arduino clock which requires no special set up. it just runs.
you have ~22 millisecond difference. loop() should run in 2 millis or (preferably) less than 1.

Finaly one step is done.

but sadly without this beautifull library.

this is the code i've been using : Arduino Uno, 4x4 keypad, 16x2 lcd, morse encoder. - Pastebin.com

and attached, is the hardware setup.

now next step is to decode the morse code from a mic.

and it can be done with the morse EnDecoder library,

here is the code :

there is somthing about the delay.

if take the
delay(preventholddelay); //delay a little to prevent continuous cycling

it will play the morse code as long as you keep the btn pressed.

now this is not right but ..... at least now i now exactly where the problem is.

does enyone have any idea on how to fix that ?

kourpetis:
does enyone have any idea on how to fix that ?

Go to the link I provided to the Nick Gammon blog on how to do multiple things at once.
The answer is there, same as before.