Chris Kelly
Well-known member
Hi guys
Just managed to get a program working on a 20M2 PICaxe! I know it sounds strange but I was amazed that it worked
It was a simple program to help with a couple of functions on my project, but it was good to actually see the process in full, from code to breadboard.
I'm, pretty hyped up now! Just wanted to say thanks for all the help so far.
Cheers
Chris
Just managed to get a program working on a 20M2 PICaxe! I know it sounds strange but I was amazed that it worked
It was a simple program to help with a couple of functions on my project, but it was good to actually see the process in full, from code to breadboard.
Code:
#picaxe 20M2
symbol inputs = b0 ' 8 bits of inputs
symbol lastInputs = b1 ' previous inputs, port B
dirsc = $00000000 ' all 8 inputs, set as needed
symbol BDmute = bit16
symbol SDmute = bit17
symbol HHmute = bit18
symbol CBmute = bit19
b2 = %11111111 ' these bits will change to
' zeroes when the
' corresponding drum is muted
symbol BDsolo = bit24
symbol SDsolo = bit25
symbol HHsolo = bit26
symbol CBsolo = bit27
b3 = 0 ' bits 24, 25, 26, 27 will change to
' 1 if a drum sound is put into SOLO mode
high B.0 ' All drums start off as unmuted
high B.1
high B.2
high B.3
main:
do
inputs = pinsc
'//// Start to monitor MUTE inputs for momentary button presses
if inputs <> lastInputs then
if bit0 <> bit8 then ' BD Mute button has been pressed
if bit0 = 1 then
if BDMute = 1 then ' toggle BD mute
BDMute = 0
else if BDMute = 0 then
BDMute = 1
endif
endif
endif
if bit1 <> bit9 then ' SD Mute button has been pressed
if bit1 = 1 then
if SDmute = 1 then ' toggle SD mute
SDmute = 0
else if SDmute = 0 then
SDmute = 1
endif
endif
endif
if bit2 <> bit10 then ' HH Mute button has been pressed
if bit2 = 1 then
if HHmute = 1 then ' toggle HH mute
HHmute = 0
else if HHmute = 0 then
HHmute = 1
endif
endif
endif
if bit3 <> bit11 then ' CB Mute button has been pressed
if bit3 = 1 then
if CBMute = 1 then ' toggle CB mute
CBMute = 0
else if CBMute = 0 then
CBMute = 1
endif
endif
endif
' //// Start to monitor SOLO inputs for momentary button presses
if bit4 <> bit12 then ' BD Solo button has been pressed
if bit4 = 1 then
if BDSolo = 0 and b3 = 0 then ' Check to make sure no other drum is already in SOLO mode
BDSolo = 1
SDMute = 0
HHMute = 0
CBMute = 0
else if BDSolo = 1 then
BDSolo = 0
SDMute = 1
HHMute = 1
CBMute = 1
end if
end if
endif
if bit5 <> bit13 then ' SD Solo button has been pressed
if bit5 = 1 then
if SDSolo = 0 and b3 = 0 then ' Check to make sure no other drum is already in SOLO mode
SDSolo = 1
BDMute = 0
HHMute = 0
CBMute = 0
else if SDSolo = 1 then
SDSolo = 0
BDMute = 1
HHMute = 1
CBMute = 1
end if
endif
endif
if bit6 <> bit14 then ' HH Solo button has been pressed
if bit6 = 1 then
if HHSolo = 0 and b3 = 0 then ' Check to make sure no other drum is already in SOLO mode
HHSolo = 1
BDMute = 0
SDMute = 0
CBMute = 0
else if HHSolo = 1 then
HHSolo = 0
BDMute = 1
SDMute = 1
CBMute = 1
end if
endif
endif
if bit7 <> bit15 then ' CB Solo button has been pressed
if bit7 = 1 then
if CBSolo = 0 and b3 = 0 then ' Check to make sure no other drum is already in SOLO mode
CBSolo = 1
BDMute = 0
SDMute = 0
HHMute = 0
else if CBSolo = 1 then
CBSolo = 0
BDMute = 1
SDMute = 1
HHMute = 1
end if
endif
endif
lastInputs = inputs
pause 40
endif
' /// Set outputs based the on mute status for each pin
if BDMute = 1 then
high B.0
low B.4
else if BDMute = 0 then
low B.0
high B.4
endif
if SDmute = 1 then
high B.1
low B.5
else if SDmute = 0 then
low B.1
high B.5
endif
if HHmute = 1 then
high B.2
low B.6
else if HHmute = 0 then
low B.2
high B.6
endif
if CBMute = 1 then
high B.3
low B.7
else if CBMute = 0 then
low B.3
high B.7
endif
loop
Cheers
Chris