[SOLVED] Print morse code to serial monitor

Hello community,

this is my demand for help, regarding to my second part of my project. In the previous part I tried to send a string to six solenoids. They should display it in Braille font. Since that worked well with some help, I am now trying to write in the serial monitor with morse through a capacitive touch sensor.

Currently I am using a code example from another mister. You can see it attached without my monster code included.
The problem is, that I am not able to combine my solenoid and the morse part... maybe I messed things up on the way. :frowning:

Thank you in advance.

PS: I really wanted to use inline code but it's too long and I'm not able to break it down, since it worked on the minimal basis. You find it attached. I'm sorry :frowning:

final_test_2.ino (17.8 KB)

morse.ino (6.24 KB)

Hi,
Late tonight but here is a way to organize combining sketches..:

https://arduinoinfo.mywikis.net/wiki/CombiningArduinoSketches

I use Morse as all control of my home automation system. Works in the dark with your eyes closed, or if you are blind...

So you spell out "Alexa turn the lights on please?" in Morse?

OP, what is the purpose of charactersToMagnets() in your code?

Hello terryking228, that's cool with your home! I apprechiate that :slight_smile:
I did everything again like in the link but it's still not working...

Hey MorganS, not exactly - I just want to write it down in the serial monitor. After that the string gets parsed and written in Braille through the solenoids.

Hi Blackfin, the charactersToMagnets() "translates" the textinput to the solenoid commands. E.g. if you type in a "a", it'll move all solenoids except for one downwards.

Thank you for your support everybody :slight_smile:

NinaBraille:
Hi Blackfin, the charactersToMagnets() "translates" the textinput to the solenoid commands. E.g. if you type in a "a", it'll move all solenoids except for one downwards.

Thank you for your support everybody :slight_smile:

This?

void charactersToMagnets() 
{
    digitalWrite(solenoidPin1, LOW);
    digitalWrite(solenoidPin2, LOW);
    digitalWrite(solenoidPin3, LOW);
    digitalWrite(solenoidPin4, LOW);
    digitalWrite(solenoidPin5, LOW);
    digitalWrite(solenoidPin6, LOW);

    while (Serial.available() == 0) 
    {           //Wait for user input

    }//while
    
}//charactersToMagnets

does nothing but turn off the solenoids and then waits for a character. It seems superfluous.

I tried a few changes to see if the Morse stuff could work with your code. Some of that included condensing the solenoid drive stuff a bit and using millis timing for the solenoid delays. I also commented out the seemingly useless charactersToMagnets for now. Compiles but not tested.

braille.ino (10.7 KB)

Hey Blackfin, I am super impressed by your work! Thank you for spending so much time and effort in finding a solution for my problem. I tried it and now the touch sensor works, but my solenoids aren't moving. :frowning:

The "charactersToMagnets()" was for leveling the solenoids when no text input is there. That's only because my solenoids heat up like crazy when their heads are down for a too long time... (solenoid: 12V, 120mA)

Maybe you have an idea why they don't move?

Oops. Sorry about that. Can you add a couple of Serial prints to showNewData:

.
.
.
        Pattern = 0x80;
        if( receivedChars[idx] >= 'a' && receivedChars[idx] <= 'z' )
            Pattern = SolenoidPatternsAlpha[ receivedChars[idx] - 'a' ];
        else
            for( int j=0; j<5; j++ )
                if( SpecialPatterns[j].Character == receivedChars[idx] )
                    Pattern =  SpecialPatterns[j].Pattern;

        Serial.println( receivedChars[idx] );  //<---- add
        Serial.println( Pattern, HEX );           // <----- add

        if( Pattern != 0x80 )

.
.
.

I want to see if the character matching is working or not.

So you spell out "Alexa turn the lights on please?" in Morse?

Actually I've been using Morse for home control since 1976. Since it's silent when lying in bed in the dark, my wife won't think I'm talking to HER. She's used to the Oley accent on the kitchen speaker.

I KNOW the Times Are A'Changing. Fast. My 14th Grandchild says, "Alexa. Play "Rock Around The Clock". I'm trying to keep SOME of the Old Times alive.

Actually I started with the software Morse in 1975 when a friend and I at IBM wrote a DOS device driver that put characters into the input buffer from a Sip-Puff switch for a young smart paraplegic kid. He couldn't speak, though... so even though the IBM Speech Recognition board was running at Yorktown, it wouldn't have worked for him.

There was a commercial software system the kid could have used. It cost $1200 back then. That pissed us off.

terryking228:
Actually I've been using Morse for home control since 1976. Since it's silent when lying in bed in the dark, my wife won't think I'm talking to HER.

Intriguing! Do you have your system documented anywhere?

Hey blackfin, I added them, but there is no text in the Serial Monitor to see. I attached the code in case I added your codesnipped falseish elsewhere...

braille.ino (10.5 KB)

That's odd. It seems to be working here; I can see the solenoid outputs being tickled with a character stream etc.

I'll attached what I've got again just to be sure. Might want to verify your baud rate etc.

braille.ino (10.7 KB)

Unfortunately they do not move when I enter a text message via the Serial monitor. :frowning: But the Morse Code works perfectly... Where or how do you see the tickled solenoids?

NinaBraille:
Unfortunately they do not move when I enter a text message via the Serial monitor. :frowning: But the Morse Code works perfectly... Where or how do you see the tickled solenoids?

Looking at pins 2, 5, 6, 7, 8 and 10 with a scope while typing strings into the serial monitor and hitting enter.

For sanity, the version of code you have that doesn't work with the Morse drives the solenoids okay, changing nothing else?

Ah okay, got it! :slight_smile: Yes, that's right.

Do you have your system documented anywhere?

I have a HugePileOfCode since this does all kinds of stuff like handling the solar pool heater, some lighting etc. And snippets for the grandchildren to listen to. If you want I can email you a ZIP. PM me your email...

This has vestiges of long-ago stuff, and maybe even from the 1997 translation from the original IBM PC Turbo PASCAL code :slight_smile:

I promised someone else I'd try to separate the pool heat code. Didn't do it :frowning:

I'm deep into writing the Arduino code for This:

https://arduinoinfo.mywikis.net/wiki/EasyConnectKit

All the examples are pre-loaded onto the Arduino-UNO - compatible board and selected with an IR remote. But I TALK about Morse :slight_smile:

Nina there's a line in the recvWithEndMarker() that prints out the message when the end marker is seen:

Serial.print(receivedChars);

Do you not see that either?

Mhm I tried to check as good as I can why there is no solenoid movement... at this point: "if (newData == true)" it seems to be that the program does not go in this "if". Like if I type "Serial.print("hello")" or something, and then type a character in the Serial monitor, there is no "hello" to see...

If I run it on my 2560 and type stuff in the monitor it outputs the following:

  • for characters not recognized in the table, Pattern is 0x80 and there's no delay indicating solenoid activity. If I type in a string of lower-case letters, it prints them one at a time with a half-second delay between them which indicates it's running through that part of the code.

If you put that "Serial.print( "hello" );" into setup, do you see it print that to the serial monitor?

Are you certain the serial monitor baud rate is set to 9600? You're on the right COM port?

braille.ino (10.8 KB)

Unfortunately all I see from my "hello" is "oo" in the Serial monitor - that's so weird. Also because it works in your program... I use an Arduino UNO with the right board and port settings, but I can't see where I can manage the Baud rate (only in the Serial Monitor which is also 9600). I use exactly the same code as you do :frowning: