'last updated 21 mar 06 'see manual for further instructions 'copyright A. Philip Pawlowski 2005 high 4 'hold power on pause 1500 setint %00001000,%00001000 'sets interrupt to receive serial commands b11 = 10 input 1 goto toolong main: for b1 = 0 to 255 if pin1 = 0 then firsthalf pause 10 goto toolong firsthalf: pause 400 'debounce contacts b1 = 0 if pin1 = 0 then toolong countfirstinterval: if b11 <> 10 then metronome b1 = b1 + 1 pause 23 if pin1 = 0 then secondhalf if b1 > 120 then toolong goto countfirstinterval secondhalf: pause 400 b2 = 0 if b11 <> 10 then metronome 'debounce contacts if pin1 = 0 then toolong countsecondinterval: if b11 <> 10 then metronome b2 = b2 + 1 pause 23 if pin1 = 0 then tallyup if b2 > 120 then toolong goto countsecondinterval tallyup: w3 = b1 * 25 w3 = b2 * 25 + 800 + w3 b4 = 60000/w3 serout 2,N2400,("stroke",#b4,13,10) if b11 <> 10 then metronome b1 = 0 b2 = 0 b3 = 0 goto main toolong: for b0 = 1 to 200 serout 2,n2400,("stroke",#b4,13,10) if b11 <> 10 then metronome pause 5 'create serial loop when rating = 0 so as not to freeze 18X b1 = 0 b2 = 0 b3 = 0 if pin1 = 0 then firsthalf next wayTooLong: b4 = 0 goto toolong interrupt: serin 3,n2400,("osca"),b11,b2 'The 18X sends commands 'Wait command stops the interrupt from re triggering on the second serial string. if b2 = 0 then PowerDown if b2 = 2 then lowBatt setint %00001000,%00001000 'sets interrupt to receive serial commands return Metronome: w6 = 60000/b11 - 100 'pause time is equal to one minute divided by rating setting less 100ms for the tone sound sound 0,(100,10) pause w6 if b11 = 10 then toolong goto metronome PowerDown: sound 0,(10,20) low 4 ' play a low note and drop power lowBatt: for b1 = 0 to 2 ' play three low notes and drop power sound 0,(120,7,10,20) pause 100 next low 4