I have been using this code http://www.efx-tek.com/php/smf/index.php?topic=2249.msg13421#msg13421
for a while.
Now, to make interpreting easier, I wonder if it's possible to break the dots and dashes between two outputs? Dots blink one light on out o, dashes blink a light on out 1?
Give this a try.
' =========================================================================
'
' File...... morse_code_v2.bs1
' Purpose... Output Morse Code message
' Author.... Scott Edwards (updated/reformatted by Jon McPhalen)
' E-mail....
' Started...
' Updated... 21 AUG 2017
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL Blinker1 = PIN1 ' for dashes
SYMBOL Blinker0 = PIN0 ' for dots
' -----[ Constants ]-------------------------------------------------------
SYMBOL YES = 1
SYMBOL NO = 0
SYMBOL IS_ON = 1 ' active-high I/O
SYMBOL IS_OFF = 0
SYMBOL DIT_TM = 250
SYMBOL DAH_TM = 750 ' 3x dit timing
SYMBOL WRD_TM = 1750 ' 7x dit timing
' -----[ Morse Code Table ]------------------------------------------------
' Encoding:
' -- upper five bits = code (0 = dit, 1 = dah)
' -- lower three bits hold # of elements
' * 6-element chars ending in dit use count 6
' * 6-element chars ending in dah use count 7
SYMBOL _A = %01000010 ' dit dah
SYMBOL _B = %10000100 ' dah dit dit dit
SYMBOL _C = %10100100 ' dah dit dah dit
SYMBOL _D = %10000011 ' dah dit dit
SYMBOL _E = %00000001 ' dit
SYMBOL _F = %00100100 ' dit dit dah dit
SYMBOL _G = %11000011 ' dah dah dit
SYMBOL _H = %00000100 ' dit dit dit dit
SYMBOL _I = %00000010 ' dit dit
SYMBOL _J = %01110100 ' dit dah dah dah
SYMBOL _K = %10100011 ' dah dit dah
SYMBOL _L = %01000100 ' dit dah dit dit
SYMBOL _M = %11000010 ' dah dah
SYMBOL _N = %10000010 ' dah dit
SYMBOL _O = %11100011 ' dah dah dah
SYMBOL _P = %01100100 ' dit dah dah dit
SYMBOL _Q = %11010100 ' dah dah dit dah
SYMBOL _R = %01000011 ' dit dah dit
SYMBOL _S = %00000011 ' dit dit dit
SYMBOL _T = %10000001 ' dah
SYMBOL _U = %00100011 ' dit dit dah
SYMBOL _V = %00010100 ' dit dit dit dah
SYMBOL _W = %01100011 ' dit dah dah
SYMBOL _X = %10010100 ' dah dit dit dah
SYMBOL _Y = %10110100 ' dah dit dah dah
SYMBOL _Z = %11000100 ' dah dah dit dit
SYMBOL _0 = %11111101 ' dah dah dah dah dah
SYMBOL _1 = %01111101 ' dit dah dah dah dah
SYMBOL _2 = %00111101 ' dit dit dah dah dah
SYMBOL _3 = %00011101 ' dit dit dit dah dah
SYMBOL _4 = %00001101 ' dit dit dit dit dah
SYMBOL _5 = %00000101 ' dit dit dit dit dit
SYMBOL _6 = %10000101 ' dah dit dit dit dit
SYMBOL _7 = %11000101 ' dah dah dit dit dit
SYMBOL _8 = %11100101 ' dah dah dah dit dit
SYMBOL _9 = %11110101 ' dah dah dah dah dit
SYMBOL Space = %00000000 ' word spacing in message
' -----[ Variables ]-------------------------------------------------------
SYMBOL char = B0 ' must use B0 for char!
SYMBOL elements = B1 ' elements in character
SYMBOL chcount = B2 ' character count
SYMBOL cidx = B3 ' character index
SYMBOL midx = B4 ' Morse element index
SYMBOL millis = W5 ' output pulse timing
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000000 ' all off
DIRS = %00000011 ' P1..P0 are outputs
' -----[ Program Code ]----------------------------------------------------
Main:
READ 0, chcount ' read # of chars
cidx = 1 ' point to first
Another:
READ cidx, char ' read char from message
GOSUB Morse ' output
cidx = cidx + 1 ' point to next
IF cidx <= chcount THEN Another ' do another if not done
GOTO Main
' -----[ Subroutines ]-----------------------------------------------------
Morse:
IF char = Space THEN Word_Space ' check for space in message
elements = char & %00000111 ' isolate element count
IF elements < 6 THEN Bang_Key ' standard character
IF elements = 7 THEN Adjust_2 ' 6-element char ends in dah
Adjust_1: ' 6-element char ends in dit
char = char & %11111011 ' put dit in 6th position
GOTO Bang_Key
Adjust_2: ' 6-element char ends in dah
elements = 6 ' correct count
Bang_Key:
FOR midx = 1 TO elements ' loop through char elements
BRANCH BIT7, (Show_Dit, Show_Dah)
Show_Dit:
Blinker0 = IS_ON
PAUSE DIT_TM
Blinker0 = IS_OFF
GOTO BK_Next
Show_Dah:
Blinker1 = IS_ON
PAUSE DAH_TM
Blinker1 = IS_OFF
BK_Next:
PAUSE DIT_TM
char = char * 2 ' left shift by 1 bit
NEXT
Char_Space:
PAUSE DAH_TM
RETURN
' -------------------------------------------------------------------------
Word_Space:
PAUSE WRD_TM
RETURN
' -----[ User Data ]-------------------------------------------------------
Message_Len:
EEPROM (8) ' address 0 in EEPROM
Message_Data:
EEPROM (_4, _2, Space, _P, _S, _I)
EEPROM (Space, Space)