' METRONOME WITH ACCENTED BEAT - PICAXE 14M ' (metronome_pgm) '----------------------------------------------------------------------------------- ' Adjustable beat rate by means of a variable resistor and timing capacitor circuit. ' Switch selectable single beat setting or a two,three,four accented beat function. ' Includes a four LED display to give a visual representation of each selected beat. ' Uses an onboard amplifier driving a small speaker to produce the metronome sounds. '----------------------------------------------------------------------------------- beat_select:' -------- beat switch (S1) selects required number of beats ---------- if input0 = 0 then beat_one if input1 = 0 then beat_two if input2 = 0 then beat_three if input3 = 0 then beat_four goto beat_select beat_four:' ---------- fourth beat - flash LED four - normal tick sound ------------ gosub charge_cap high 3 sound 4,(860,3) pause 50 low 3 gosub discharge_cap 'goto beat_three beat_three:' --------- third beat - flash LED three - normal tick sound ------------ gosub charge_cap high 2 sound 4,(860,3) pause 50 low 2 gosub discharge_cap 'goto beat_two beat_two:' ------------ second beat - flash LED two - normal tick sound ------------ gosub charge_cap high 1 sound 4,(860,3) pause 50 low 1 gosub discharge_cap 'goto beat_accent beat_accent:' --------- first beat - flash LED one - accented tick sound ----------- gosub charge_cap high 0 sound 4,(830,3) pause 50 low 0 gosub discharge_cap goto beat_select beat_one:' ------------ single beat - flash LED one - normal tick sound ------------ gosub charge_cap high 0 sound 4,(860,3) pause 50 low 0 gosub discharge_cap goto beat_select charge_cap:'---------- delay at start of beat while capacitor (C1) charges.--------- high 5 pause 10 readadc 4,b1 if b1 < 150 then charge_cap return discharge_cap:'------- delay at end of beat while capacitor (C1) discharges.-------- low 5 pause 10 readadc 4, b1 if b1 > 50 then discharge_cap return '----------------------------------------------------------------------------------- ' b1 = ADC input 0 to 255 upper threshold set at 150 ' lower threshold set at 50 '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- 'NOTE: Beats are numbered in reverse ending at beat one or the accented beat. ' This makes it posible to use the same code with all four beat sequences. '-----------------------------------------------------------------------------------