\ Morse Code on the LaunchPad. 
\ Connections:   P2.0 --->------8 Ohm Speaker-----<---GND   

DECIMAL

VARIABLE /freq
VARIABLE duration

: init         ( -- )     
  1 $2A C! 1 $2E C!   ( P2.0 connected to TA1.0) 
  $80 $182 !  ( TA1.0 toggle mode)
  $1000 $192 ! ( TA1CCR0, period )
  500 /freq !  100 duration ! ; ( init them, or app save fails!)
: tone $210 $180 ! ; ( SMCLK, count up )
: stop ( -- )   0 $180 ! 0 $21 C! ;  ( stop tone and LEDs)
: pause       ( d -- )    FOR /freq @ FOR NEXT NEXT ; 
: red	1 $21 C! ;
: green $40 $21 C! ;
: short duration @ pause ; 
: long  duration @ 3 * pause ; 

: dit  init red tone short stop short ; 
: dah  init green tone long stop short ; 
: ..   stop long ;   ( inter-element gap between the dots and dashes ) 

\ Morse Alphabet 
: A dit dah .. ; 
: B dah dit dit dit .. ; 
: C dah dit dah dit .. ; 
: D dah dit dit .. ; 
: E dit .. ; 
: F dit dit dah dit .. ; 
: G dah dah dit .. ; 
: H dit dit dit dit .. ; 
: I dit dit ; 
: J dit dah dah dah .. ; 
: K dah dit dah .. ; 
: L dit dah dit dit .. ; 
: M dah dah .. ; 
: N dah dit .. ; 
: O dah dah dah .. ; 
: P dit dah dah dit .. ; 
: Q dah dah dit dah .. ; 
: R dit dah dit .. ; 
: S dit dit dit  .. ; 
: T dah .. ; 
: U dit dit dah .. ; 
: V dit dit dit dah .. ; 
: W dit dah dah .. ; 
: X dah dit dit dah .. ; 
: Y dah dit dah dah .. ; 
: Z dah dah dit dit .. ; 
: _0 dah dah dah dah dah .. ; 
: _1 dit dah dah dah dah .. ; 
: _2 dit dit dah dah dah .. ; 
: _3 dit dit dit dah dah .. ; 
: _4 dit dit dit dit dah .. ; 
: _5 dit dit dit dit dit .. ; 
: _6 dah dit dit dit dit .. ; 
: _7 dah dah dit dit dit .. ; 
: _8 dah dah dah dit dit .. ; 
: _9 dah dah dah dah dit .. ; 

: //  stop 7 FOR short NEXT ; ( Pause between words) 

\ Commonly used two letter procedural signals 

: AA   A A ;    ( End Of Line)
: AAA  A A A ;  ( Full Stop)
: AR   A R ;    ( End of message)
: AS   A S ;    ( Stand by; wait)
: BK   B K ;    ( Break )
: BT   B T ;    ( Separation - break - between address and text; text + signature)
: CL   C L ;    ( Going off the air: clear)
: CQ   C .. Q ; ( Calling any amateur radio station)
: DE   D E ;    ( This or From)
: GB   G B ;    ( Good bye, God Bless)
: GD   G D ;    ( Good, Good Day)
: GE   G E ;    ( Good Evening )
: HH   H H ;    ( Error sending. 8 dits, Transm. cont., last word correctly sent.) 
: II   I I ;    ( Short form of above <HH> )
: IMI  I M I ;  ( Repeat; I say again. Difficult or unusual words or groups.)
: KA   K A ;    ( Beginning of message)
: KN   K N ;    ( Go only, invite a specific station to transmit)
: NR   N R ;    ( Number follows )
: OK   O K ;    ( Correct)
: SGD  S G D ;  ( Signed)
: SK   S K ;    ( Out; clear - end of communications, no reply expected.) 
: SOS  dit dit dit dah dah dah dit dit dit .. ; 
( Mayday! Without character pauses!) 
: VE   V E ;    ( Understood)


: >>  F O R T H  // I S // S U P E R  ; 

: TITANIC  BEGIN SOS // ?KEY UNTIL DROP ; 

: ZEN
   Z E N // F O R // _4 _3 _0 // L A U N C H P A D // AR
;

( finis)