PICAXE as Arpeggiator

The purpose of this exercise was to try out the sound command really.

With the sound command you can put out a sound at a pitch to any of the output pins. Its just a square wave. Unforturnatly its not very asynchronous so when you kick off a 100ms note you lose control of everything else. Lets face it…a 1 second note is an ETERNITY to a micro processor. However, the way the PICAXE works is that you are trading having to deal with interrupts for a simple command. From what I can tell, there is no way around this (except for using an external source to trigger an interrupt..but thats another test).

ya, the Picaxe is not the best sound source. Well it is kinda, but you just gotta be creative. This particular exercise did not explore much beyond creating simple sounds and reading from the ADC.

The program is as follows:

symbol rndW=w5
symbol rndB=b10
symbol tempo =1   'tempo controller
symbol note = 4   'starting note controller
symbol PIEZO0=0   'piezo speaker

symbol tmpNote=b3
symbol tmpSpeed=b4

init:

start:

' ### read note and speed
readadc tempo,tmpSpeed
readadc note,tmpNote

' adjust values a bit to a reasonable value
let tmpSpeed = tmpSpeed / 5 MIN 1
let tmpNote = tmpNote / 4 MIN 4

' ## play first note
sound PIEZO0,(tmpNote, tmpSpeed)

pause tmpSpeed

'  ### play second note
tmpNote = tmpNote + 10  '  note + 10
sound PIEZO0,(tmpNote, tmpSpeed)

pause tmpSpeed

'  ### play third note
tmpNote = tmpNote + 10
sound PIEZO0,(tmpNote, tmpSpeed)

pause tmpSpeed

goto start

Nothing too special. Two pots control the speed and the starting note.

The sound command puts out a sound for a specified amount of time. Values from 0 to 127 (or so) are notes and from 128 to 255 are a pitched noise. This program picks values that are within the sound range so I divide the number by 4 to give me a range from 1 to 63 or so.

Basically it reads the tempo and pitch and uses those values to kick off a three note arpeggio.

The synchronous nature of the chip can be felt by selecting a slow rate and cranking it to a fast one. You have to wait for the whole slow sequence to finish before the fast one kicks off.

so anyway….this works. Not well…but it works.

picaxe_arp.v1

Back to PICAXE projects