Please point me to some step by step basics to code the PICAXE using Blockly.

lbenson

Senior Member
Why did you use only one poke statement in " twinkle" and 3 in " simple gifts"?
There's a limit to how many characters can be in a picaxe command line. The number of bytes needed for Simple Gifts exceeded the allowed line length.
 

Gramps

Senior Member
That would include commas and spaces and everything correct?
Why did you select poke 56, 90, and 112?
 
Last edited:

Gramps

Senior Member
Using poke statements in the commands in the manual is pretty skimpy.
Is there a explanation and overview available somewhere?
Does it have to be an exact count?
How did you select the first poke number?
 

Gramps

Senior Member
When we load Twinkle (post 282) on the 40X2 the LEDs do not wait for the hammer strike but run through the whole sequence.
Any ideas!??
EDit, Appears to have a sodering short to ground on pin C.0.............
Edit, Pin is not shorted......
 
Last edited:

lbenson

Senior Member
When we load Twinkle (post 282) on the 40X2 the LEDs do not wait for the hammer strike but run through the whole sequence.
Any ideas!??
EDit, Appears to have a sodering short to ground on pin C.0.............
Short on C.0 to ground should not cause it to run through. Short high or pulled high on either C.0 or C.1 would.
 

lbenson

Senior Member
I recall it's over 1000 these days. Probably 1023 or 1024 including CR-LF line endings.
I got an error when I first tried to poke the whole of "Simple Gifts". I just assumed it was line length. I'll try again--it would certainly be easier if one POKE statement could do the whole thing.
 

lbenson

Senior Member
Simple Gifts. This worked fine on a single line in both PE6 and PE5, so I don't know what problem I originally encountered which made me break it into multiple lines.
Code:
' 28SimpleGifts
#picaxe 28x2
symbol _D=B.1
symbol E=B.2
symbol Fs=B.3
symbol G=B.4
symbol _A=B.5
symbol _B=B.6
symbol _C=B.7
symbol DD=B.0
' Twinkle, Twinkle, Little Star
'poke 56,_D,_D,_A,_A,_B,_B,_A, G,G,Fs,Fs,E,E,_D, _A,_A,G,G,Fs,Fs,E, _A,_A,G,G,Fs,Fs,E, _D,_D,_A,_A,_B,_B,_A, G,G,Fs,Fs,E,E,_D, $ff
' Simple Gifts
poke 56,_D,_D,G,G,_A,_B,G,_B,_C,DD,DD,_C,_B,_A,G,_A,_A,_A,G,_A,_B,_A,Fs,_D,_D,G,Fs,G,_A,_B,_C,DD,_B,_A,G,_A,_A,_B,_B,_A,G,G,G,G,DD,_B,_A,_B,_C,_B,_A,G,_A,_B,_B,_C,DD,_A,_A,_B,_A,_D,G,G,_A,_B,_B,_C,DD,_C,_B,_A,_A,_B,_B,_A,G,G,G,$FF
bptr=56 ' above top named variable 
do : high @bptr : Do : Loop Until pinC.0 = 1 or pinC.1 = 1 : low @bptrinc : Pause 100 : loop until @bptr = $ff
 

Gramps

Senior Member
'Working light chaser using lbenson's code
Note: LEDs do not wait for hammer strike.

New symbols config.

'Inputs: C.0 and C.1
'Unused pins: A.4, A.5, and A.6
'Keep open C.3 and C.4 to use I2C eeprom for storage as needed.
'(and its also possible to use an I2C display).
code:
#picaxe 40x2

'RAY 1
symbol _D6=A.7
symbol _C6=C.2
symbol _B5=D.0
symbol _A5=D.1
symbol _G5=D.2
symbol _Fs5=A.3
symbol _E5=C.7
symbol _D5=C.6
symbol _Cs5=A.2
symbol _B4=D.4
symbol _A4=D.2
symbol _Gs4=A.1

'RAY 2 Excluding duplicates
symbol _F5=A.0
symbol _C5=C.5
symbol _G4=D.5
symbol _Fs4=B.7
symbol _E4=D.7
symbol _D4=D.6
symbol _Cs4=B.6

'RAY 3 Excluding duplicates
symbol _Bb4=B.5
symbol _F4=B.4
symbol _C4=B.3
symbol _B3=B.2
symbol _A3=B.1
symbol _G3=B.0

poke 56, _D5, _C4, _A4, _G4, _Fs4, _E4, _D4, $ff
bptr=56 ' above top named variable
do : high @bptr : Pause 250 : Do : Loop Until pinC.0 = 1 or pinC.1 = 1 : low @bptrinc : Pause 250 : loop until @bptr = $ff
 

lbenson

Senior Member
Works for me in simulation. Before the POKE statement, put

if pinC.0 = 1 or pinC.1 = 1 then : sertxd("C.0 or C.1 is high",cr,lf) : endif

If the line prints, then you have a problem with C.0 or C.1.

(Which reminds me, do you have a pulldown on C.0 and C.1? If not (and no pullup either), then the pin is "floating" and may be either high or low at any given time. Check manual 3 for required wiring for pushbutton input pins.)
 

Gramps

Senior Member
That must be what's happening. Because even without a wire on pin C.1 or C.0 when I bring my hand near the pins, the LEDs pause!
What about the other unused pins should they be pulled down also?
 

lbenson

Senior Member
Pulling down unused pins +may+ be of use when running off of battery and trying to minimize current draw, but in other cases is not likely to be required.
 

Gramps

Senior Member
We're assuming both of the input pins must each have a 1k and 10k resister installed as described in Manual 3. Correct?
Edit: Installed resisters as instructed. Inputs are now working properly!
 
Last edited:

Gramps

Senior Member
Have 25 LEDs driven by 25 pins.
A headache to get the right pins to the right symbols!
Note we standardized all the symbols. Hope that doesn't mess up the code...........
Edit; They are all working!!!
 
Last edited:

Gramps

Senior Member
Yes Sir!
'(We have one A4 note (of 3) not lighting. )
'Working light chaser using lbenson's code
'First three lines of Hiding in Thee
'Inputs: C.0 and C.1
'Added pull down resisters to input pins.
'Unused pins: A.4, A.5, and D.0
'Keep open C.3 and C.4 to use I2C eeprom for storage as needed.(and its also possible to use an I2C display).

code:
#picaxe 40x2

'RAY 1
symbol _D6=A.7
symbol _C6=C.2
symbol _B5=A.6
symbol _A5=D.1
symbol _G5=D.3
symbol _Fs5=A.3
symbol _E5=C.7
symbol _D5=C.6
symbol _Cs5=A.2
symbol _B4=D.4
symbol _A4=D.2
symbol _Gs4=A.1

'RAY 2 Excluding duplicates
symbol _F5=A.0
symbol _C5=C.5
symbol _G4=D.5
symbol _Fs4=B.7
symbol _E4=D.7
symbol _D4=D.6
symbol _Cs4=B.6

'RAY 3 Excluding duplicates
symbol _Bb4=B.5
symbol _F4=B.4
symbol _C4=B.3
symbol _B3=B.2
symbol _A3=B.1
symbol _G3=B.0

poke 56, _C5, _C5, _Bb4, _A4, _A4,_G4, _F4, _F4, _E4, _D4, _E4, _F4, _F4, _Bb4, _A4, _D5, _C5, _A4, _F4, _G4, _A4, _B4, _C5, _C5, _C5, _C5, _Bb4, _A4, _A4, _G4, _F4, _F4, _E4, _D4, _F4,$ff

bptr=56 ' above top named variable
do : high @bptr : Pause 250 : Do : Loop Until pinC.0 = 1 or pinC.1 = 1 : low @bptrinc : Pause 250 : loop until @bptr = $ff
 

lbenson

Senior Member
The best way to have a large, maybe huge, number of tunes available would be to implement an "abc" notation reader on the picaxe. Here is a first pass at that, with "Simple Gifts", aka "Lord of the Dance". There are a lot of abc versions of Simple Gifts. I found one here that is close to what I am familiar with, in the key of G: http://abcnotation.com/tunePage?a=trillian.mit.edu/~jc/music/abc/Contra/reel/Simple_Gifts_RJ/0000

For anyone who wants to know more about abc encoding, there's this page: http://abcnotation.com/wiki/abc:standard:v2.2

I made special use of this: http://abcnotation.com/wiki/abc:standard:v2.2#the_tune_body

Code:
' 40ABC_reader ' plays tune from ABC musical notation
'   see here for abc:
'     http://abcnotation.com/wiki/abc:standard:v2.2#the_tune_body
#picaxe 40x2

symbol pPiezo=A.4

'RAY 1
symbol _D6=A.7
symbol _C6=C.2
symbol _B5=A.6
symbol _A5=D.1
symbol _G5=D.3
symbol _Fs5=A.3
symbol _E5=C.7
symbol _D5=C.6
symbol _Cs5=A.2
symbol _B4=D.4
symbol _A4=D.2
symbol _Gs4=A.1

'RAY 2 Excluding duplicates
symbol _F5=A.0
symbol _C5=C.5
symbol _G4=D.5
symbol _Fs4=B.7
symbol _E4=D.7
symbol _D4=D.6
symbol _Cs4=B.6

'RAY 3 Excluding duplicates
symbol _Bb4=B.5
symbol _F4=B.4
symbol _C4=B.3
symbol _B3=B.2
symbol _A3=B.1
symbol _G3=B.0
'abc note designation starting with G below treble clef:
'G, A, B, C D E F G A B c d e f g a b c' d'
' additional commas go lower, e.g. "G,,", additional quotes go higher

symbol eeloc=b3 ' eeprom location
symbol abcCh=b4 ' abc notation character
symbol key=b5 ' abc notation character
symbol abcNote=b6 ' abc notation note
symbol abcNoteNo=b7 ' abc notation note number out of "ABCDEFGabcdefg"
symbol octave=b8 '
symbol abcDuration=b9 ' abc note duration: 2=1/4;3=3/8;4=1/2;6=3/4;8=whole
                      ' note picaxe tune only supports 1/8, 1/4, 1/2, 1
symbol note=b10 ' coded for picaxe tune command: duration:octave:note
symbol scratch=b11 '
symbol noteCount=b12 '

' Simple Gifts
' write tune in ABC notation to eeprom
data 0,("K:G D2D2|G4G2A2|B2G2B2c2|d4d2c2|B4A2G2|A4A4|A4G4|A2B2A2F2|D4D4|G2D2G2A2|B4B2c2|d4d2c2|B4A2G2|A4A2A2|B4B2A2|G4G3A|G8||d8|B6A2|B3cB2A2|G6A2|B4B2c2|d4c2B2|A4A2B2|A4D2D2|G4G2A2|B4B2c2|d4d2c2|B4A2G2|A4A4|B4B2A2|G4G4|G4|ZZZ")
eeloc = 0 ' first eeprom location
read eeloc,abcCh
if abcCh = "K" then ' key designation; if absent, assume "D"
  eeloc = eeloc + 2 ' skip colon
  read eeloc,key
  inc eeloc
  read eeloc,abcCh ' first note of tune
endif
do
  sertxd(abcCh)
  if abcCh = " " or abcCh = "|" then ' skip white space
  else ' process character
'    lookdown abcCh,("ABCDEFGabcdefg"),abcNoteNo
    lookdown abcCh,("CDEFGABcdefgab"),abcNoteNo ' abc encoding
    if abcNoteNo > 0 then ' it's a note
      abcNote = abcCh
      inc eeloc
      read eeloc,abcCh ' possible octave shift
      inc eeloc
      if abcCh = "," or abcCh = "'" then ' octave is shifted up/down
      else
        abcCh = ""
        dec eeloc ' move back to read possible next note or duration
      endif
      if key <> "Z" then ' (all keys)
      ' for hammer dulcimer, shift everything down one octave
        if abcNoteNo > 6 then
          octave = 6  ' picaxe middle octave
          if abcCh = "'" then : octave = 7 : endif ' octave is shifted up
          ' note was lower case--make upper
          if abcNote > "Z" then : abcNote = abcNote - 32 : endif
        else
          octave = 5 ' picaxe low octave
        endif
      else
      endif
      read eeloc,abcDuration ' possible duration--default is 1/16th
      if abcDuration = "2" or abcDuration = "3" or abcDuration = "4" or abcDuration = "6" then
      else
        abcDuration = ""
        dec eeloc ' move back to read possible next note
      endif
      gosub playnote
    endif ' end of "we found a note"
  endif
  inc eeloc
  read eeloc,abcCh ' next note of tune
loop until abcCh = "Z" ' end of tune

end

playnote:
  inc noteCount
  if noteCount = 21 then
    pause 1            '' break simulation here
  endif
  scratch = abcNote - "A" ' convert to 0-7 for ABCDEFG
  '               A     B    C D E F G
  lookup scratch,(9,11,0,2,4,5,7),note
  select key ' "C" = no sharps
    case "D"   ' two sharps
      if abcNote = "F" or abcNote = "C" then : inc note : endif
    case "G"   ' one sharp
      if abcNote = "F" then : inc note : endif
    case "A"   ' three sharps
      if abcNote = "F" or abcNote = "C" or abcNote = "G" then : inc note : endif
  endselect
  select octave
    case 5  : note = note + %00100000 ' picaxe low octave
    case 6  : note = note + %00000000 ' picaxe middle octave
    case 7  : note = note + %00010000 ' picaxe high octave
  endselect
  select abcDuration
    case ""  : note = note + %01000000 ' 1/8
      tune pPiezo,8,(note)
    case "2" : note = note + %00000000 ' 1/4
      tune pPiezo,8,(note)
    case "3" : note = note + %00000000 ' 3/8: 1/4 + 1/8
      tune pPiezo,8,(note)
      note = note + %01000000 ' 1/8
      tune pPiezo,8,(note)
    case "4" : note = note + %11000000 ' 1/2
      tune pPiezo,8,(note)
    case "6" : note = note + %00000000 ' 3/4: 1/4 + 1/2
      tune pPiezo,8,(note)
      note = note + %11000000 ' 1/8
      tune pPiezo,8,(note)
    case "1" : note = note + %10000000 ' 1
      tune pPiezo,8,(note)
  endselect
  return
This plays in simulation--very slowly, even at the fastest simulation speed. With a piezo on A.4, it should play with the timing approximately right on a real picaxe.

Accidentals, triplets, and other features are not available due to the limitation of the picaxe tune encoding (only 1/8, 1/4, 1/2, and whole notes possible, though I fudged to get 3/8ths and 3/4ths).

The next step is to add the note-to-LED encoding that gramps has provided. A large library of abc-coded tunes could fit into an external EEPROM. These could be played with the piezo turned off so that it did not interfere with the player's timing, or with the piezo turned on for learning that timing.
 
Last edited:

hippy

Technical Support
Staff member
The best way to have a large, maybe huge, number of tunes available would be to implement an "abc" notation reader on the picaxe.
Another alternative is some mobile phone Ring Tone format. The advantage being that there are hundreds of those available, in RTTTL formats and others.

Anything which abstracts what needs to be done when playing a tune into a more understandable and easier way to specify what that tune is has to be welcomed, especially if not wanting to have to hand convert every song one wants to use.

There are basically three levels of specifying a tune -

Specifying the pins which need to be activated per note, which can be aided by using Symbol definitions for those notes.

Using a notational language like 'abc' or RTTTL, including that in the PICAXE program and having the PICAXE convert that into the pins which need to be activated.

Putting the notation in a computer text file and having some additional utility program which generates what needs to be included with the PICAXE program to play a particular tune.

This is effectively what the PICAXE Editor Tune Wizard does, but it only generates what TUNE sequences should be, isn't general purpose.

Which leads on to considering where tunes are stored; within the PICAXE program or elsewhere, externally.

Within the program means there is limited storage space and that may restrict the size of tunes, and will require a separate program per tune or set of tunes. Want a different tune and one may need to download a new program. Not always convenient.

Using external I2C allows more tunes, but can be problematic when it comes to adding new tunes.

External SD Card or other other removable memory which can be taken to a PC or other PICAXE system to update would be convenient but more complex and complicated to implement.

It seems that 'proof of concept' has been proven, and it might be worth taking a brief step back to decide what it is one wants before deciding what needs to implemented and how best that should be done.
 

lbenson

Senior Member
Another alternative is some mobile phone Ring Tone format. The advantage being that there are hundreds of those available, in RTTTL formats and others.
Back when this thread began I looked at the ring tone format and (some of) the hundreds/thousands of tunes available. I did not see that there was a good fit between the kinds of tunes available--which, even when what might be wanted were often truncated--and what would be likely to be played on a hammered dulcimer.

On the other hand, the abc notation is widely and actively used by thousands of players of guitar, fiddle, banjo, mandolin, recorder--it is used by performing musicians. It can be scribbled on a scrap of paper for exchange at tune fests. And there is a vast library which can be searched at http://abcnotation.com/ -- right now they claim 580,000 tunes.

I agree that the question of how to get the tunes into a picaxe is a problem--especially for a library of tunes. Here for starters, though, it's just a matter of cut and paste (with perhaps a little editing).
... might be worth taking a brief step back
But ... but ... my practice seems to be, "code first, think later".
 
Last edited:

hippy

Technical Support
Staff member
On the other hand, the abc notation is widely and actively used by thousands of players of guitar, fiddle, banjo, mandolin, recorder--it is used by performing musicians.
I wasn't aware of 'abc' notation but I have to admit you've convinced me.

When I developed some software years ago to create PICAXE 'sound' commands to play tunes I seem to have missed that one as a possible input format. It looks like it should be easy enough to convert 'abc' tunes to something which a PICAXE could handle; pretty much as per your Post #343.

I would probably favour a transparent two-stage approach, going from 'abc' to key number plus note length, as that's then easy to convert to either a LED to light or a tone to actually generate.

Looks like you should be able to coerce what you have into what's needed.
 

Gramps

Senior Member
We want to replace the inputs (hammers shorting to positive) on the light chaser with a Radio Shack Microphone.
Has 5+, ground and a signal pin. The specs say the signal is HIGH when no sound is detected and LOW when sound is over 105 dB.
This does not appear to be an analog device, so it should connect to pin C.0 and change the code to read "Loop Until pinC.0 = 0".
Edit; Well it works only with HARD hits. Normal playing doesn't trip the LEDs............
Edit; We placed the mike over the sound hole and it works better but now we are getting some double trips perhaps because of echo?
 
Last edited:

lbenson

Senior Member
What Radio Shack microphone are you using? When searching for "microphone" on radioshack.com, I don't see one which matches your description--3 wires and sound level detection. I could use one of those, especially if the sound level is adjustable. (There are many fitting that description on ebay, but in the past I did not find that I could tune them for what I needed.)
 

Gramps

Senior Member
Picked it up years ago online. It's not adjustable. Found a link when I Googled it but I can't seem to post it. Appears to have a transistor, several resisters and a cap mounted on the back.
 

Attachments

Last edited:

Gramps

Senior Member
Beginning with post #321 we started a discussion about pokes.
Could you elaborate some more on how pokes are used?
 

lbenson

Senior Member
Could you elaborate some more on how pokes are used?
The POKE statement is used to put bytes of data into a location or a string of locations in the RAM memory of the picaxe (this is volatile memory--the contents are lost if you power-cycle or reprogram). The 28X2 and 40X2 have 255 bytes of RAM memory, as explained in the "Variables - Storage" section of Manual 2. This includes the "General", or named variables, b0-b55, which occupy ram locations 0-55.

A POKE statement, which, as hippy suggested above with regard to statement length, might be as much as 1,023 characters long, can fill the "upper" RAM (above b55) with data with a single statement. You can then retrieve that data and process it with PEEK statements, or with the pointer variable, bptr.

There are basically three places where you can store bulk data internally in a 28X2 or 40X2--in eeprom (255 bytes--non volatile), in RAM (255 bytes, effectively minus the named variables), and the scratchpad (1024 bytes). You read/write to them with the READ/WRITE, PEEK/POKE, and PUT/GET commands respectively. In addition to the bptr pointer variable for accessing RAM, there is a ptr variable for accessing the scratchpad. (Actually there is a fourth place--you can use TABLE data.)

You might want to print out the PICAXE Memory Mapping pdf prepared by westaust; post 24 here: https://picaxeforum.co.uk/threads/picaxe-memory-map-and-sfr-details-chart.11514/
 
Last edited:

Gramps

Senior Member
Thank you! That 3 paragraphs will take a bit of thinking!

Could you describe a set up to test input devices?
20181205_122333.jpg
This seems to have a digital output but has no specifications.
How to tell what it's doing?
 

lbenson

Senior Member
I would guess that the "+" pin is not used. 0V goes to "-" and your picaxe output pin goes to "S" (for Signal, I think). If that doesn't do it, connect your picaxe pin to "+".

For testing, this worked for me on a 20M2 with piezo hooked up on C.7, and worked in simulation on a 40X2, so I think should work for you if you copy and paste it into PE6. Don't expect much in the way of sound quality.
Code:
' 20tune
#picaxe 40x2 '20M2
#no_data

'tune 5, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16)
'tune 5, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
'tune 5, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$11,$D1,$4B,$0B)
' omit following line for full tune
''tune 5, 8,($44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$10,$10,$4B,$0B)
'tune 5, 8,($51,$12,$09,$46,$06,$42,$29,$02,$06,$49,$52,$12,$06,$44,$04,$42,$01,$C2,$49,$51,$69,$42,$46,$49,$52,$56,$59,$52,$12,$16,$54,$14,$49,$11,$12,$D2)

'tune 5, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
'tune 5, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$D0,$4B,$0B,$51,$12,$09,$46,$06,$42,$29,$02,$06,$49,$52,$12,$06,$44,$04,$42,$01,$C2,$49,$51,$69,$42,$46,$49,$52,$56,$59,$52,$12,$16,$54,$14,$49,$11,$12,$D2)
' Ashokan Farewell
sertxd(cr,lf,"Ashokan Farewell",cr,lf)
tune C.7, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
tune C.7, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$D0,$4B,$0B,$51,$12,$09,$46,$06,$42,$29,$02,$06,$49,$52,$12,$06,$44,$04,$42,$01,$C2)
tune C.7, 8,($49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$56,$16,$57,$16,$D4,$49,$51,$52,$12,$51,$4B,$49,$C6,$44,$46,$47,$07,$46,$44,$42,$2B,$42,$02,$6B,$29,$02,$06,$09,$12,$16,$09,$11,$14,$D2)
tune C.7, 8,($46,$47,$49,$09,$46,$02,$D2,$09,$4B,$0B,$51,$12,$49,$46,$06,$04,$46,$06,$44,$02,$EB,$27,$29,$E9,$C9,$46,$44,$02,$06,$09,$10,$D0,$4B,$0B,$51,$12,$09,$46,$06,$42,$69,$42,$46,$49,$52,$56,$59,$52,$12,$16,$54,$14,$49,$11,$12,$D2)
' Temperance Reel
'sertxd(cr,lf,"Temperance Reel",cr,lf)
'tune C.7, 8,($42,$44,$46,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$47,$49,$46,$47,$46,$44,$42,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$52,$49,$46,$07)
'tune C.7, 8,($42,$44,$46,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$47,$49,$46,$47,$46,$44,$42,$07,$47,$46,$47,$49,$4B,$50,$12,$57,$54,$52,$4B,$49,$50,$4B,$44,$44,$42,$44,$46,$47,$49,$4B,$47,$49,$46,$C7)
'tune C.7, 8,($4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$49,$52,$52,$54,$12,$52,$54,$56,$52,$59,$56,$57,$56,$54,$52,$4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$4B,$49,$47,$46,$44,$46,$47,$49,$4B,$52,$49,$46,$C7)
'tune C.7, 8,($4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$49,$52,$52,$54,$12,$52,$54,$56,$52,$59,$56,$57,$56,$54,$52,$4B,$54,$54,$52,$14,$54,$56,$57,$54,$59,$56,$57,$56,$54,$52,$4B,$49,$47,$46,$44,$46,$47,$49,$4B,$47,$49,$46,$47,$46,$44,$42)
 
Last edited:

Gramps

Senior Member
Thanks for the suggestion but I was wondering if there's some way to actually read data coming off the Piezo
We want to use the Piezo as an input
We Have a " Snark super tight all instrument tuner."
Upon dissecting it we found that the pickup unit is a Piezo that looks exactly like this one except it's only 3/8 of an inch in diameter.
Would a piezo output be an analog signal?
If so it would be possible to set it at a threshold level that would make a pin go high similar to the way the accelerometer input works?
 

lbenson

Senior Member
... We want to use the Piezo as an input
Ah, got it. Again, no connection to "+" I think, "-" to 0V, "S" to picaxe ADC pin. For testing, read the pin repeatedly and display the result--maybe 10 times a second. Determine empirically when a note has been struck. The piezo has to be well attached to a vibrating surface on the hammer dulcimer. (At least, on a guitar, they are glued/adhered to the guitar top near the sound hole.)
Code:
do
  readadc pinno, b1
  sertxd(#b1," ")
  pause 100
loop
This will produce 10 values a second, so you need to watch carefully. Vary the force of the strike so you can see what the threshold is for a light stroke. Then in real code you will say IF b1 > ### THEN ' you have a strike, so do something. You may need more than 10 reads a second (I think the piezo peak is determined by vigor of the vibration.) (I don't know what limits the amplitude of the signal to 5V.) When used as a guitar pickup, the frequency is measured/used as well as the amplitude--I don't think you need that.

You'll need to figure out what kind of pause you need after detecting a strike so that you don't act multiple times for a single strike.

Can you see if the "+" is actually connected to anything on the board? If so, provide a clear photo.
 
Last edited:
Top