PLAY THE DARTH VADER MARCH ARDUINO!

Published

Introduction: PLAY THE DARTH VADER MARCH ARDUINO!

About: Your one stop place for electronics tutorials, components and services!

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!

Share

    Recommendations

    • Planter Challenge

      Planter Challenge
    • Casting Contest

      Casting Contest
    • Clocks Contest

      Clocks Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    3 Comments

    Ok thanks I will do that straight away!

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