PICAXE
PICAXE
Flashing Crossing Lights on Steroids!
–Program 5:
Symbol Tone = 100 'sets the tone frequency ( range 20 -127 )
Symbol Quiet = 0 'set quiet tone
Symbol Dit_length = 7 'set length of a dot     (7 milliseconds)- yields 10wpm
Symbol Dah_length = 21 'set length of a dash (21 mS = 3 dots long)
Symbol Wrd_Length = 86 'set space between words (43 mS = 2 dashes, 6 dots)
Symbol Character = b0 'set register for ch.
Symbol Index1 = b6 'loaded with number of chs. in message
Symbol Index2 = b2 'counts the number of elements
Symbol Elements = b4 'set register for number of elements in ch.
Start:
Identify: ' routine to lookup ch.& put its value into the ch. register
   for Index1 = 0 to 29 'cycle through lookup for times = number of ch. in message
lookup Index1,(0,1,0,1,0,0,100,0,2,0,129,0,129,0,3,0,132,0,35,0,67,0,195,0,4,0,0,1,0,1),Character
gosub Morse 'go to the ch. generation routine 
  next 'loop back to get next ch. and load it
  goto Start 'return to start to wait for next input
Morse:
let Elements = Character & %00000111 'look at 3 LS digits and load into Elements register
if Elements = 0 then Word_sp ' % means binary
Bang_Key:
  for Index2 = 1 to elements 'loop through correct no. of times for number of elements
  if Character >= 128 then Dah 'test MS digit of ch. If it is 1 goto the Dah sub routine
goto Dit 'if it is 0 goto the Dit sub routine
Reenter:
  let Character = Character * 2 'do a left shift on all the bits in ch.
   next 'loop back to get the next element
  gosub Char_sp 'go to sub routine to put in inter-ch. space
return 'return to Identify routine to get next ch. to send
Dit:
sound 2,(Tone,Dit_Length) 'sound tone for dit length
 sound 2,(Quiet,Dit_Length) 'silence for dit length
goto Reenter 'return to look at next element of ch.
Dah:
sound 2,(Tone,Dah_Length) 'sound tone for dah length
 sound 2,(Quiet,Dit_Length) 'silence for dit length
goto Reenter 'return to look at next element of ch.
Char_sp:
 sound 2,(Quiet,Dah_Length) 'send silence for dah length after ch.completely sent
return 'return to get next character
Word_sp:
 sound 2,(Quiet,wrd_length) 'send silence for break between words
return 'return to get next ch.
Reprogram Lighthouse /w LEDs for Morse code
(PA # 3) Show Morse code unit -  if time is good demo the end-user-programmable Morse unit
OK to copy / paste
2006 NGRC – 43 min to here