Groups keyboard shortcuts have been updated
Dismiss
See shortcuts
Skip to first unread message

Slice of Life

unread,
Jan 26, 2018, 9:12:28 AM1/26/18
to MIT App Inventor Forum
hello,
i am trying to convert a message to morse code vibrations.
 Actually, i want to take each alphabet letter and tune a vibration depending on the alphabet and the morse code of it using app inventor.
i am new to app inventor so can someone plz help me or provide documents or tutorials.
thanks in advance

SteveJG

unread,
Jan 26, 2018, 9:29:29 AM1/26/18
to MIT App Inventor Forum

You can use two Lists and an mp3 sound file for each character


The sound files, lists of the letters/characters and their “dot-dash” representations and various settings are loaded when the app loads are generated by using two CSV files;


The morseCharacters csv string is:

'/','.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..','.----','..---','...--','....-','.....','-....',--...','---..','----.','-----',.-.-.-',..--..',-...-'

The letters/numerals/punctuation (morseLetters) are:

/ ,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0,.,?,/ 


Store each csv file is stored internally in the app as a csv (comma separated value) file and are converted with an AI2 block into a List.



A mp3 sound file is necessary for each letter of the alphabet, numeral and punctuation. These are obtained from Wikipedia https://en.wikipedia.org/wiki/Morse_code  Yes, you have to download one at a time.



Alternatively, you can visit the MIT Gallery   and search for morse  .  There are several example apps there that might be easier to work with.


Good luck.

Regards,
Steve

Abraham Getzler

unread,
Jan 26, 2018, 11:21:08 AM1/26/18
to MIT App Inventor Forum
You will probably need these blocks:

segment, from the Text block section

the Player event block that gains control when a played file ends

a global index into your input text

the Lookup in Pairs block from the Lists section,
to turn letters into .mp3 file names

the Media Drawer in the Designer

ABg

TimAI2

unread,
Jan 27, 2018, 7:11:17 PM1/27/18
to mitappinv...@googlegroups.com
For the lazy among you, find alphabet,numbers and SOS sounds in the attached zip

Source: as above from Wikipedia

:)
morsecode.zip

Ghica

unread,
Jan 28, 2018, 6:19:07 PM1/28/18
to MIT App Inventor Forum
Of course you need only two mp3 files, one with a long and one with a short beep.
And if you only want to do vibrations, as Daisy said, you do not even need that!
Just for fun I attached an .aia that does it.
It is actually not so easy. You must convert a string to a list. The list starts with an empty string I found, so, you should start at 2 to go through it.  Then find its index in the list of letters and numbers. And take that index to find the morse code. 
Then, to make the sound you have again to make a list of a string of the morse code. You have to insert some waiting for blanks between words. 
It would have been slightly easier if the when.Player.Completed event would fire after the vibration, but it does not. Again a wait timer is needed to make it continue. 
Here are the blocks:

Cheers, Ghica.


morse.aia

TimAI2

unread,
Jan 28, 2018, 6:51:20 PM1/28/18
to MIT App Inventor Forum
Nice work Ghica :)

SteveJG

unread,
Jan 28, 2018, 7:12:22 PM1/28/18
to MIT App Inventor Forum
@ Ghicia If one wants proper Morse code with proper dot-dash spacing, one must use the mp3 files  or  adjust your code for the timing. Your example seems ok if someone just wants to play.

-- Steve

Ghica

unread,
Jan 29, 2018, 6:22:44 AM1/29/18
to MIT App Inventor Forum
@Steve
Perfection is the enemy of good enough.
>> The question of Daisy was: i am trying to convert a message to morse code vibrations.
I think we should respect that. She also said that she was a beginner. The list juggling needed is not for the faint of heart.
(Is there a better way to convert a string to a list than my split by empty string trick?)

I based my timings on this:
If the duration of a dot is taken to be one unit then that of a dash is three units. The space between the components of one character is one unit, between characters is three units and between words seven units. 

Yes, the timings could be improved, it was not quite clear to me if vibrate was done asynchronously. It seems so, so I tried to adjust for that. The advantage of mp3 files would be louder sound and the possibility to use when.Player.Completed event, but still you need only two. Maybe it is actually a bug that the event does not fire for vibrations?

My solution does not consider all the extra and special codes you could use, but if Daisy want and knows more about App Inventor she could try herself.
I attached my slightly modified version, which translates a space to / instead to 7 spaces to get the right silence between words, and slightly modified timings to try to have 100 ms time between sounds always.

For a little midnight exercise I had fun with it and I hope it helps Daisy.
Cheers, Ghica.


morse_2.aia

Juan Antonio

unread,
Jan 29, 2018, 1:28:25 PM1/29/18
to MIT App Inventor Forum
Other example of (simple) Morse, is in Spanish...


p59C_codigo_morse.aia
Reply all
Reply to author
Forward
0 new messages