Step 9Program the chip
CPU = 16F877
MHZ = 20
CONFIG = 16254
SI con A0
SCK con A1
RCK con A2
abit var byte(9)
nDur var word(8)
nP var word(8)
counter var byte
setValue var byte
noteDuration var word
notePause var word
'shift register address bits
abit(0) = %10000000
abit(1) = %01000000
abit(2) = %00100000
abit(3) = %00010000
abit(4) = %00001000
abit(5) = %00000100
abit(6) = %00000010
abit(7) = %00000001
abit(8) = %00000000
'duration array pins
nDur(0) = D0
nDur(1) = D1
nDur(2) = D2
nDur(3) = D3
nDur(4) = D4
nDur(5) = D5
nDur(6) = D6
nDur(7) = D7
'pause array pins
nP(0) = B0
nP(1) = B1
nP(2) = B2
nP(3) = B3
nP(4) = B4
nP(5) = B5
nP(6) = B6
nP(7) = B7
counter = 0
setValue = %00000000
main:
for counter = 0 to 7
HIGH nDur(counter)
pause 1
RCTIME nDur(counter),1,noteDuration
setValue = abit(counter)
gosub out595
pause noteDuration
HIGH nP(counter)
pause 1
RCTIME nP(counter),1,notePause
setValue = abit(8)
gosub out595
pause notePause * 3
next
counter = 0
goto main
out595:
shiftout SI, SCK, LSBPRE,[setValue\8]
pulsout RCK, 8
Return
| « Previous Step | Download PDFView All Steps | Next Step » |


























































for instance this one will receive midi and output clock pulses.
http://www.blacet.com/MSdata.html
each time it recieves a clock is when it steps to the next value, start/stop start and stop the sequencer, and reset puts it back to the beginning.
it makes music equipment much more useful if they all know what time to do stuff.
then you can do something like this.
http://www.youtube.com/watch?v=c2HCReBtQYU