Pages: [1]   Go Down
Author Topic: Piezo buzzer - Winning and loosing sound FX  (Read 1133 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
Logged

London
Offline Offline
Edison Member
*
Karma: 47
Posts: 1437
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What have you got so far?
Post your code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

actually ive been searching around and now ive got this far but the timing and tones it out for a winning sound :/
Code:
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);
  
}
« Last Edit: September 13, 2013, 07:58:34 pm by jmsgarton » Logged

Pages: [1]   Go Up
Jump to: