Jeremy Leach
Senior Member
A while back I was wondering about this. Just to say I've experimented now and it couldn't be easier...
<code><pre><font size=2 face='Courier'>
Picaxe 08M
.-----------.
| |
+5V -| |- 0V
| |
-| |-
| |
.---------|Out4 |-
| | |
| -| Out2|-------.
| | | |
| '-----------' |
| |
| |
| -----------
| Piezo
| -----------
| |
'-----------------------------o
.-.
| |
| |4.7K
'-'
|
o-------------------------------.o--------------o
</font></pre></code>
Example code:
<code><pre><font size=2 face='Courier'>
#picaxe 08m
Symbol SoundPin = 2
Symbol VolPin = 4
Symbol BeatInterval = 500 'ms
'INITIALISE:
Output SoundPin
'MAIN:
Goto Threefour
'SUBROUTINES:
ThreeFour:
Gosub AccentedTick
Gosub NormalTick
Gosub NormalTick
Goto ThreeFour
AccentedTick:
Low VolPin
sound SoundPin, (255,2)
pause BeatInterval
Return
NormalTick:
Input VolPin
sound SoundPin, (230,2)
Pause BeatInterval
Return
</font></pre></code>
The 'Volume' pin, pin4 is set as an input to apply the resistor in series with the Piezo (lowered volume), and is set low to short the resistor (max volume).
The sound command is using the 'white noise' values to get a 'tick' sound. I expect the actual sound will vary depending on the specific piezo etc, but it sounds good to me !
Edited by - jeremy leach on 15/04/2007 10:06:27
<code><pre><font size=2 face='Courier'>
Picaxe 08M
.-----------.
| |
+5V -| |- 0V
| |
-| |-
| |
.---------|Out4 |-
| | |
| -| Out2|-------.
| | | |
| '-----------' |
| |
| |
| -----------
| Piezo
| -----------
| |
'-----------------------------o
.-.
| |
| |4.7K
'-'
|
o-------------------------------.o--------------o
</font></pre></code>
Example code:
<code><pre><font size=2 face='Courier'>
#picaxe 08m
Symbol SoundPin = 2
Symbol VolPin = 4
Symbol BeatInterval = 500 'ms
'INITIALISE:
Output SoundPin
'MAIN:
Goto Threefour
'SUBROUTINES:
ThreeFour:
Gosub AccentedTick
Gosub NormalTick
Gosub NormalTick
Goto ThreeFour
AccentedTick:
Low VolPin
sound SoundPin, (255,2)
pause BeatInterval
Return
NormalTick:
Input VolPin
sound SoundPin, (230,2)
Pause BeatInterval
Return
</font></pre></code>
The 'Volume' pin, pin4 is set as an input to apply the resistor in series with the Piezo (lowered volume), and is set low to short the resistor (max volume).
The sound command is using the 'white noise' values to get a 'tick' sound. I expect the actual sound will vary depending on the specific piezo etc, but it sounds good to me !
Edited by - jeremy leach on 15/04/2007 10:06:27