'------------------------------------------------------------------- 'Program MORSE2.BS2 -- Designed for the BASIC Stamp II 'This program provides a four message keyer for Amateur Radio. 'Richard Clemens, KB8AOB -- Version 1.0 'clemens@academ.wvwc.edu 'The user can input four different messages in msg1-msg4, 'their character counts in msc1-msc4, and use four 'buttons to display the output and/or key a transmitter. 'NB: the messages are limited to the upper and lower case 'letters, digits 0-9, space, period, comma, ? and / 'Program is based on the information in Stamp I - Note 8 'and uses some code from that note. See Note 8 for details. '------------------------------------------------------------------- 'load the EEPROM with data 'switch, special characters, A-M, N-Z, and 0-9 '(switch is so we only convert data after an initial load) swtc data 0 spec data 0,87,207,54,149 leta data 66,132,164,131,1,36,195,4,2,116,163,68,194 letn data 130,227,100,212,67,3,129,35,20,99,148,180,196 nums data 253,125,61,29,13,5,133,197,229,245 'user can change the messages below msg1 data "CQ CQ CQ de KB8AOB KB8AOB KB8AOB K" msg2 data "QTH QTH is Buckhannon, WV Buckhannon, WV" msg3 data "UR RST RST is 599 599 NAME NAME HR IS RICH RICH" msg4 data "TNX for QSO and 73 de KB8AOB" 'character counts must match messages above msc1 con 34 msc2 con 40 msc3 con 48 msc4 con 28 'various constants. See Note 8 for some details tabl con 41 tone con 1200 spc con 380 dit con 70 dah con 210 'some places to do the work chr var b0 ele var b1 x1 var b2 x2 var b3 x3 var b4 x4 var b5 'initialize pins 0 and 1 for output high 0 low 1 'clear the button variables b8 = 0 b9 = 0 b10 = 0 b11 = 0 'test to see if we just downloaded, if yes, set the 'switch so we don't try this again and then convert all 'the messages into their morse code bytes read 0,chr if chr <> 0 then loop write 0,255 'using the ASCII codes to shorten the lookdown 'replace each character with its morse code byte 'tabl is the number of elements in the table of codes cvt_msgs: x2 = tabl + 1 x3 = tabl + msc1 + msc2 + msc3 + msc4 for x1 = x2 to x3 read x1,chr lookdown chr,[32,46,44,63,47],chr if chr > 4 then nspec chr = chr + 1 goto find 'if not a space, period, comma, ? or / then 'sort out the numbers, small letters, and capitals 'and compute a pointer for the table of codes nspec: if chr > 90 then sml if chr > 57 then cap chr = chr - 16 goto find sml: chr = chr - 91 goto find cap: chr = chr - 59 find: read chr,chr write x1,chr next 'Jump here if not a new program load and then 'wait for a button to be pressed. (All ready to go 'for the Stamp Experiment Board!) 'input on pins 8-11 for messages 1-4 loop: button 8,0,255,0,b8,1,msg1_o button 9,0,255,0,b9,1,msg2_o button 10,0,255,0,b10,1,msg3_o button 11,0,255,0,b11,1,msg4_o goto loop 'output the desire message msg1_o: x3 = tabl + 1 x4 = msc1 + tabl goto msg_o msg2_o: x3 = msc1 + tabl + 1 x4 = msc1 + msc2 + tabl goto msg_o msg3_o: x3 = msc1 + msc2 + tabl + 1 x4 = msc1 + msc2 + msc3 + tabl goto msg_o msg4_o: x3 = msc1 + msc2 + msc3 + tabl + 1 x4 = msc1 + msc2 + msc3 + msc4 + tabl msg_o: for x1 = x3 to x4 gosub code next goto loop 'routines to send the 0's and 1's of the morse 'code bytes as dits and dahs (See Note 8) code: read x1,chr if chr <> 0 then sendit pause spc return sendit: gosub Morse return morse: ele = chr & %00000111 if ele = 7 then Adj1 if ele = 6 then Adj2 key: for x2 = 1 to ele if chr >= 128 then dah_o goto dit_o shift: chr = chr * 2 next pause dah return Adj1: ele = 6 goto key Adj2: chr = chr & %11111011 goto key dit_o: low 0 freqout 1,dit,tone high 0 pause dit goto shift dah_o: low 0 freqout 1,dah,tone high 0 pause dit goto shift '-------------------------------------------------------------------