Go Down

Topic: Piezo buzzer - Winning and loosing sound FX (Read 1 time) previous topic - next topic


Hello guys, I'm using an piezo buzzer in my project and after looking around the internet ive been able to create a code which makes a simple siren alarm sound but I am unable to find online the next step which im looking to code into my project. I am making a game and if the user wins i would like the piezo buzzer to play and winning noise or if the user looses I would like it to play a loosing noise. for the winning noise I just want it to do "der der der der der deerrrr" but obviously in the correct tones and for the loosing noise something like "der deerrr" or something better if anyone can come up with that. Im not sure on even how to start with this code so if anyone could help me do them two things i would be very grateful  :)


What have you got so far?
Post your code.


well that's the thing I haven't got anywhere with this, not sure even where to start with the sounds. the alarm sound FX is not related to this


Sep 07, 2013, 06:53 pm Last Edit: Sep 14, 2013, 02:58 am by jmsgarton Reason: 1
actually ive been searching around and now ive got this far but the timing and tones it out for a winning sound :/
Code: [Select]

int piezo = 34;

float sinVal;
int toneVal;

void setup() {
 pinMode (piezo, OUTPUT);

void loop() {

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131