Have been waiting for some bits from futerlec for ages still havent received them
so my projects on hold.. was intrigued about what a metronome is
so i thought id hav a go
hope i get some feedback if its not quite right or if any1 can offer some suggestions
thanks in advance lol!
it will display the number pattern 1 2 3 4 across the four seqments.
it can also be set to 1 2 3 or display a 1 2 pattern.
at a rate that can be set between 30 beats per minute and 254 beats per minute.
When powered on it will display a 4 so u can see its been set to a 4 beat pattern.
push the button it will start at 60 beats per minute which has been preset.
if you hold on the button you can select from a menu (b,2,3,4,r)
push to cycle hold to select 2or 3 or 4 selects beat pattern.
hold on b(beats perminute) and will display 60 hold will exit a push enables you to select between30 and 254 hold and exit you can now use the new rates.
if we want to save the new setting select r(remember)in the menu and hold.
just using the basic hardware setup i use for most my code examples .
so my projects on hold.. was intrigued about what a metronome is
so i thought id hav a go
hope i get some feedback if its not quite right or if any1 can offer some suggestions
thanks in advance lol!
it will display the number pattern 1 2 3 4 across the four seqments.
it can also be set to 1 2 3 or display a 1 2 pattern.
at a rate that can be set between 30 beats per minute and 254 beats per minute.
When powered on it will display a 4 so u can see its been set to a 4 beat pattern.
push the button it will start at 60 beats per minute which has been preset.
if you hold on the button you can select from a menu (b,2,3,4,r)
push to cycle hold to select 2or 3 or 4 selects beat pattern.
hold on b(beats perminute) and will display 60 hold will exit a push enables you to select between30 and 254 hold and exit you can now use the new rates.
if we want to save the new setting select r(remember)in the menu and hold.
Code:
' -- -- -- --
' B0-A | | | | | Picaxe 20x2 ver C.0
' B1-B
' B2-C | | | | | Marks
' B3-D -- -- -- -- -- --
' B4-E | | | |
' B5-F
' B6-G | | | |
' -- -- -- --
'
'Display 1 2 3 4
'Common anode C.3 C.2 C.1 C.0
SYMBOL display1 = C.3
SYMBOL display2 = C.2
SYMBOL display3 = C.1
SYMBOL display4 = C.0
SYMBOL DP = A.0
SYMBOL Pushbutton = PINC.6
SYMBOL Push = B3
SYMBOL Character = B4
SYMBOL Beat = B5 '1 2 3 4 displayed beat
SYMBOL BPM = B6 '30 to 254
SYMBOL NumberOfBeats = B7 '2or3or4 beat pattern
SYMBOL Hold = W8
SYMBOL BeatsPerMinute= W9
SYMBOL BPMval1 = W10
SYMBOL BPMval2 = W11
eeprom 0,(192,249,164,176,153,146,130,248,128,144,255) 'Character ,(0,1,2,3,4,5,6,7,8,9,blank)
eeprom 11,(131,164,176,153,175) 'menu Character,(b,2,3,4,r)
eeprom 20,(60,4) 'bpm,beats
READ 20,BPM
READ 21,numberofbeats
main:
LET dirsb = %11111111
LET dirsc = %10111111
ConvertBPM: HIGH display3 : IF pushbutton = 1 THEN ConvertBPM
LET BeatsPerMinute = BPM ' BPM calculated at default 8mhz
BPMval1=50000 /BeatsPerMinute*30/4*5 'calculate beats per minute
BPMval2=50000//BeatsPerMinute*30/4*5/BeatsPerMinute 'ie 250 beats per minute = 58036
BeatsPerMinute=BPMval1+BPMval2 'ie 30 beats per minute = 3036
BeatsPerMinute=-BeatsPerMinute
Initialise: HIGH DP : hold=0 : push=0
SETTIMER BeatsPerMinute
TIMER = 0
BeatDisplay:
beat=TIMER//numberofbeats
IF beat = 0 THEN LET beat = NumberOfBeats : ENDIF
character = 10: IF beat <> 1 THEN dig1 ' blanking
LET character = beat
Dig1: HIGH display4 : READ character, pinsb : LOW display1 : PAUSE 1 'Display1
IF pinc.6 = 1 THEN selection
character = 10: IF beat <> 2 THEN dig2 ' blanking
LET character = beat
Dig2: HIGH display1 : READ character, pinsb : LOW display2 : PAUSE 1 'Display2
character = 10: IF beat <> 3 then dig3 ' blanking
LET character = beat
Dig3: HIGH display2 : READ character, pinsb : LOW display3 : PAUSE 1 'Display3
character = 10: IF beat <> 4 then dig4 ' blanking
LET character = beat
Dig4: HIGH display3 : READ character, pinsb : LOW display4 : PAUSE 1 'Display4
ON push GOTO initialise,beatdisplay
Selection:
IF hold > 800 THEN Menu
inc hold
IF pushbutton = 1 THEN selection
push = push + 1//2
ON push GOTO initialise,beatdisplay
Menu:character = 11 :LOW DP : IF pushbutton = 1 THEN Menu
Men:hold=0
READ character,pinsb : LOW display1 : PAUSE 1 : HIGH display1
PAUSE 2
IF pushbutton=0 THEN men 'Display menu
Menu1:HIGH display1
IF hold > 700 then Menuselection 'Hold to select
INC hold
LOW display1 : IF pushbutton = 1 THEN menu1
INC character 'Roam menu on release
IF character = 16 THEN menu
GOTO men
Menuselection:IF pushbutton = 1 THEN Menuselection
SELECT CASE character
CASE 11 : GOTO BPMDisplay
CASE 12 TO 14 : LET numberofbeats = character-10 : GOTO initialise
CASE 15 : WRITE 20,BPM : WRITE 21,numberofbeats : GOTO initialise
END SELECT
BPMDisplay:HIGH a.0:hold =0
LET character = BPM DIG 2
READ character ,pinsb : LOW display1 : PAUSE 1 : HIGH display1
LET character = BPM DIG 1
READ character,pinsb : LOW display2 : PAUSE 1 : HIGH display2
LET character = BPM DIG 0
READ character,pinsb : LOW display3 : PAUSE 1 : HIGH display3
IF pinc.6 = 1 THEN selection1
GOTO BPMDisplay
Selection1:
IF hold > 800 THEN ConvertBPM
INC hold
IF pushbutton = 1 THEN selection1
mselect: IF pushbutton = 1 THEN mselect : LET BPM = 0
mselec: hold = 0
LET character = BPM DIG 2
READ character,pinsb : LOW display1 : PAUSE 1 : HIGH display1
IF pushbutton=0 THEN mselec
msele:low display1 : IF hold > 700 then mslect
INC hold : HIGH display1
IF pushbutton = 1 THEN msele
BPM = BPM + 100
IF character = 3 THEN mselect
GOTO mselec
mslect:LET BPMval2 = BPM : IF BPM < 100 THEN LET BPMval2=30 : ENDIF
HIGH display1 :IF pushbutton = 1 THEN mslect
mslec:hold = 0
LET character = BPM DIG 2
READ character,pinsb : LOW display1 : PAUSE 1 : HIGH display1
LET character = BPMval2 DIG 1
READ character,pinsb : LOW display2 : PAUSE 1 : HIGH display2
IF pushbutton=0 THEN mslec
msle:low display2 : IF hold > 700 THEN mmselect
INC hold : HIGH display2
IF pushbutton = 1 THEN msle
BPMval2 = BPMval2 + 10
IF character = 9 or bpmval2 > 250 THEN mslect
GOTO mslec
mmselect: LET BPM = BPMval2 : HIGH display2 : IF pushbutton = 1 THEN mmselect
mmselec: hold = 0
LET character = BPM DIG 2
READ character,pinsb : LOW display1 : PAUSE 1 : HIGH display1
LET character = BPM DIG 1
READ character,pinsb : LOW display2 : PAUSE 1 : HIGH display2
LET character = BPM DIG 0
READ character,pinsb : LOW display3 : PAUSE 1 : HIGH display3
IF pushbutton=0 THEN mmselec
mmsele:low display3 : IF hold > 700 then ConvertBPM
INC hold : HIGH display3
IF pushbutton = 1 THEN mmsele
INC BPM
IF character = 9 or BPM = 255 THEN mmselect
GOTO mmselec
Attachments
-
171.8 KB Views: 161
Last edited: