ericgfx:
<...>
I want to use the Millis interval check just to get the practice of using it, but for my purpose seems overly complex. As I understand it, the millis interval check is great for doing processes simultaneously, but for this project I execute one process at a time.
<...>
Welcome to the forum!
The function millis() is a counter that increments every millisecond, or 1000 a second. There is another timer, micros() that implements every microsecond. When you assign an unsigned long variable, UL, the value of the millis() function, that variable can be used as the beginning time for an event. So, if the variable was UL beginTime, then after you did some work you could print the value of millis() - beginTime and have the duration of the measured process.
Disregarding all of the background (DMA) and look-ahead (pipelining) features in modern microcontrollers, the cpu simply is a single threaded unit... there is no multiprocessing or parallel processing going on. It is all rather basic stuff.
Dots and Dashes sound a lots like Morse Code. So, sending out PARIS in Morse looks something like the below:
char PARIS(byte Letter)
{
switch(Letter)
{
case 0: // P
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'P';
case 1: // A
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'A';
case 2: // R
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin,toneHz); delay(DAHmS); // <dah>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'R';
case 3: // I
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
noTone(toneOutPin); delay(DITmS); // <quiet>
return 'I';
case 4: //S
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin); delay(DITmS); // <quiet>
tone(toneOutPin, toneHz); delay(DITmS); // <dit>
noTone(toneOutPin);
return 'S';
}
}
When the timing looks like
void setspeed(byte value) // see:http://kf7ekb.com/morse-code-cw/morse-code-spacing/
{
WPM = value;
DITmS = 1200 / WPM;
DAHmS = 3 * 1200 / WPM;
// character break is 3 counts of quiet where dah is 3 counts of tone
// wordSpace = 7 * 1200 / WPM;
wordBreak = 7 * DITmS; // changed from wordSpace*2/3; Key UP time in mS for WORDBREAK (space)
Elements = MaxElement; // International Morse is 5 characters but ProSigns are 6 characters
halfDIT = DITmS/2; // Minimum mS that Key must be UP (quiet) before MM assignment to dot/dash
quarterDIT = DITmS/4; // Minimum accepted value in mS for a DIT element (sloppy)
halfDAH = DAHmS/2; // Maximum accepted value in mS for a DIT element (sloppy)
DITDAH = DITmS + DAHmS;// Maximum accepted value in mS for a DAH element (sloppy)
DiDiDi = DITmS * 3; // Minimum mS that Key must be up to decode a character via MM
}
Ray