3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Simple Sequencer

Step 9Program the chip

Program the chip
Program the 16f877 chip with the following code and then transfer it into the socket.

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 StepDownload PDFView All StepsNext Step »
6 comments
May 17, 2012. 7:00 AMstealthop says:
what pic programmer is that?
Apr 13, 2011. 1:21 AMapaterson1 says:
i have no programing experience do u know where i can find a pre-programmed chip? thanks
Nov 19, 2011. 6:53 AMblinkyblinky says:
You can use a 4017...
Aug 14, 2011. 8:35 PMhintss says:
sell them
Jun 18, 2009. 7:07 AMneutron7 says:
is there any way to change this program to accept an external clock source?
for instance this one will receive midi and output clock pulses.
http://www.blacet.com/MSdata.html
Jun 18, 2009. 4:35 PMneutron7 says:
you can use MIDI to synchronise your sequencer to other music gear or programs such as reason, cubase, ableton live etc.
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

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
2360
Followers
200
Author:randofo(Randy Sarafan loves you!)
I am the Technology Editor here at Instructables. I am also the author of the books 'Simple Bots,' and '62 Projects to Make with a Dead Computer'. Subscribing to me = fun and excitement!