14m sequencer

boriz

Senior Member
Here’s the first prototype sequencer. Just a proof-of-principal really. It only has 4 slots so can only play a repeating sequence of 4 notes. The input is via 2 buttons (pin0,pin2) and a pot on adc0. There are 4 LEDs (pins 2,3,4,5) that indicate the currently playing note, another LED on pin0 to indicate the mode, and the sound comes from a piezo connected to pin1.

When first run, it’s in play mode and the LEDs light in sequence, one LED on at a time. The speed is controlled via the pot. No note’s are programmed, so no sound is heard. Pressing the mode button once changes to program mode. LEDs stop sequencing and the Prog LED comes on. A tone can be heard and it’s frequency is changed using the pot. Half of the pots travel is tones, the other half noise (as indicated in the docs under SOUND command).

This is the note that will be programmed into the currently indicated slot. To store the note, press and hold the slot button for about half a second. The slot button also advances the slot indicator. To change slots, press the slot button briefly.

Program the sequence of notes, then press the mode button to change back to play mode. Now the LEDs will start to light in sequence again, but as each LED comes on, it’s corresponding note is heard.

During programming, a silence can be programmed by turning the pot all the way to zero before storing the note.

I could use the 4 LEDs as a binary display and with just a small change to the code, have a 16 slot sequence. I’m currently exploring the possibility of getting 8 LEDs/slots to work. In theory the 14M could have upto 48 slots, but I don’t know how the display would work. I’d prolly need to add more components, like a 7seg LED driver maybe.

As published here, this sequencer can be constructed using just a 14M, 5 LEDs, 2 buttons with 4K7 pullups, 1 pot and a Piezo disk.

Code:
#picaxe 14m

low 2,3,4,5

pla:
do
	readadc 0,b1:b1=b1/10
	gosub adv
	b2=b2+$50:peek b2,b0:b2=b2-$50
	sound 1,(b0,b1)
	if pin1=0 then
		high 0
		pause 300
		goto prg
	endif
loop

prg:
do
	readadc 0,b0
	sound 1,(b0,5)
	if pin1=0 then
		low 0
		pause 300
		goto pla
	elseif pin2=0 then
		pause 300
		if pin2=0 then
			b2=b2+$50
			poke b2,b0
			b2=b2-$50
		else
			gosub adv
		endif
	endif
loop

adv:
low b2
inc b2
if b2=6 then
	b2=2
endif
high b2
if pin2=0 then
	pause 300
endif
return
 
Last edited:

westaust55

Moderator
Hi boriz,

Not in a position to try your code but from a quick look:

Out of sheer curiosity, any reason why you use the SOUND command as opposed to the TUNE command?

in your subroutine "‘adv:”
if you could use outputs 0 to 3 for the 4 LED’s, then

code]
Adv:
low b2
inc b2
b2 = b2 AND %00000011 ; mask to use only lower 2 bits for 0,1,2 & 3
high b2
:
:
[/code]
would/should save a few bytes with no IF . . . THEN test needed.

If you wanted to operate more LED's then the ubiquitous 74HC595 needs just 3 outputs (less than you are currently using to drive 4 LED's), and can be daisy chained for multiples of 8 outputs.
 
Last edited:

boriz

Senior Member
I’m sure there’s lots of opportuneity (Ahem) for code optimisation should it become necessary. ATM it’s only using 107 of 256 available bytes.

While the TUNE command is playing a sequence of notes, there can be no response to inputs, and it can only use one specific output. SOUND is more versatile than TUNE. The note durations could be stored along with the note frequencies adding significantly more functionality.
 

westaust55

Moderator
While the TUNE command is playing a sequence of notes, there can be no response to inputs, and it can only use one specific output.
Think you are confusing the 08M (pin 2 only) with the other PICAXE chips where you can select which output (0 to 7) to use.
 
Top