// Star Wars Imperial March (John Williams' masterpiece) // copy-paste from http://paste2.org/p/123617 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.htm 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