PLAY THE DARTH VADER MARCH ARDUINO!
by Jacks how2s in Circuits > Arduino
1498 Views, 19 Favorites, 0 Comments
PLAY THE DARTH VADER MARCH ARDUINO!


What you need
Arduino
speaker/Buzzer
Computer with arduino software
Pins

The positive pin goes to digital pin 11
And the negitive goes to the GND pin
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!