Introduction: PLAY THE DARTH VADER MARCH ARDUINO!

Picture of PLAY THE DARTH VADER MARCH ARDUINO!

What you need

Arduino

speaker/Buzzer

Computer with arduino software

Step 1: Pins

Picture of Pins

The positive pin goes to digital pin 11

And the negitive goes to the GND pin

Step 2: Coding

Picture of 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!

Comments

ÁdámS66 (author)2016-01-24

Here is a working example of this project, with the whole code

http://pastebin.com/cjE4HQnY

(Not my work)

Jacks how2s (author)2016-01-14

Ok thanks I will do that straight away!

ThomasK19 (author)2016-01-14

To make your code above readable, you should use the paragraph symbol in the editor and select Code.

About This Instructable

941views

19favorites

License:

Bio: Go to jackshow2s.weebly.com for more! Also Check Out Me On YouTube!
More by Jacks how2s:How to Make An Automatic Coffee Pod Dispenser With ArduinoHow to Make a 555 Timer Blink Circuit on a PCB!DIY 3D Printed Fidget Spinner
Add instructable to: