YARPF

Raspberry Pi Logo YetAnotherRaspberryPiFanpage

5.0 - Un Buzzer

Plan

wiring plan

Board

bread board

Code

int pinSpeaker = 6;
 
int numTones = 6;
int tones[] = {261, 294, 330, 349, 392, 440};
//              C    D    E    F    G    A
 
void setup()
{
  pinMode(pinSpeaker, OUTPUT);
}
 
void loop()
{
  
  for (int i = 0; i < numTones; i++)
  {
    tone(pinSpeaker, tones[i]);
    delay(500);
  }
  
  delay(3000);
}

Download

Fritzing: buzzer.fzz

Comments ?

blog comments powered by Disqus