loading

What you need

Arduino

speaker/Buzzer

Computer with arduino software

Step 1: Pins

The positive pin goes to digital pin 11

And the negitive goes to the GND pin

Step 2: Coding

The code is

int ledPin = 13;

//led for visualization (use 13 for built-in led)

int speakerPin = 11; //speaker connected to one of the PWM ports

#define c 261 #define d 294 #define e 329 #define f 349 #define g 391 #define gS 415 #define a 440 #define aS 455 #define b 466 #define cH 523 #define cSH 554 #define dH 587 #define dSH 622 #define eH 659 #define fH 698 #define fSH 740 #define gH 784 #define gSH 830 #define aH 880 //frequencies for the tones we're going to use //used http://home.mit.bme.hu/~bako/tonecalc/tonecalc.ht... to get these

void setup() { pinMode(ledPin, OUTPUT); // sets the ledPin to be an output pinMode(speakerPin, OUTPUT); //sets the speakerPin to be an output } void loop() // run over and over again { march(); } void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds) { digitalWrite(ledPin, HIGH); //use led to visualize the notes being played int x; long delayAmount = (long)(1000000/frequencyInHertz); long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2)); for (x=0;x

GO TO jackshow2s.weebly.com FOR MORE OF MY PROJECTS!

<p>Here is a working example of this project, with the whole code<br><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/mBiq-eXGxb0" width="500"></iframe></p><p><a href="http://pastebin.com/cjE4HQnY" rel="nofollow">http://pastebin.com/cjE4HQnY</a><br><br>(Not my work)</p>
Ok thanks I will do that straight away!
<p>To make your code above readable, you should use the paragraph symbol in the editor and select Code.</p>

About This Instructable

927views

19favorites

License:

Bio: Go to jackshow2s.weebly.com for more! Also Check Out Me On YouTube!
More by Jacks how2s:DIY 3D Printed Fidget Spinner 555 Timer Blink Circuit! 555 Timer Monstable Circuit! 
Add instructable to: