Go Down

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

jmsgarton

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  :)

Henry_Best

What have you got so far?
Post your code.

jmsgarton

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

jmsgarton

#3
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() {
 tone(piezo,500,200);
 delay(200);
 tone(piezo,500,200);
 delay(200);
 tone(piezo,500,200);
 delay(200);
 tone(piezo,800,150);
 delay(150);
 tone(piezo,500,500);
 delay(500);
 tone(piezo,600,1000);
 delay(10000);
 
}

Go Up