Brandon Michelsen
Published © GPL3+

Arduino Musical Tesla Coil

This is a musical Tesla Coil driven by an Arduino and Slayer-Exciter. Using an Arduino, you can play music with pure electricity!

IntermediateWork in progress2 days25,991
Arduino Musical Tesla Coil

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
TIP31C
×1
4N35
×1
Resistor 10k ohm
Resistor 10k ohm
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Tesla Coil Schematic

This is the schematics for the circuit.

Tesla Coil Schematic

The Fritzing schematic file.

Code

Arduino Music Generator

Arduino
This is used to play the music on the Tesla Coil
/*****************************************************************
 * This is a basic file to play music through an Arduino.
 * 
 * Author: Brandon Michelsen
 * Date: 11/25/2017
 * 
 */

//Define the music pin
#define musicPin 10

//Include the tones file
#include "Tones.h"

//Constructor for the music playing function
void playMelody(float melody[], float durations[]);

//Create a tones array
float tetrisMusic[] =  {
  0, 0, 0, NOTE_E4, NOTE_E4, NOTE_B3, NOTE_C4, NOTE_D4, NOTE_C4, NOTE_B3, NOTE_A3, NOTE_A3, NOTE_C4, NOTE_E4, NOTE_D4, NOTE_C4, NOTE_B3, NOTE_B3, NOTE_C4,
  NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_A3, 0, NOTE_D4, NOTE_F4, NOTE_A4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_C4, NOTE_E4, NOTE_D4, NOTE_C4, 
  NOTE_B3, NOTE_B3, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_C4, NOTE_A3, NOTE_A3, 0, NOTE_E3, NOTE_C3, NOTE_D3, NOTE_B2, NOTE_C3, NOTE_A2, NOTE_GS2, NOTE_B2,
  NOTE_E3, NOTE_C3, NOTE_D3, NOTE_B2, NOTE_C3, NOTE_E3, NOTE_A3, NOTE_A3, NOTE_GS3
};

//Create durations
float tetrisDurations[] = {
  4, 4, 4, 4, 4, 8, 8, 4, 8, 8, 4, 8, 8, 4, 8, 8, 4, 8, 8, 4, 4, 4, 4, 4, 4, 4.5, 8, 4, 8, 8, 4.5, 8, 4, 8, 8, 4, 8, 8, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 
  2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 1
};

void setup() {
  //Set the music pin as an output
  pinMode(musicPin, OUTPUT);
}

void loop() {
  //Play the music
  playMelody();
  delay(1000);
}

//Function for playing melodies
void playMelody(){
  //Variables for note durations and pause times
  float noteDuration;
  float pause;
  
  //Loop through the notes
  for(int thisNote = 0; thisNote < (sizeof(tetrisMusic)/sizeof(float))/*Get the array length*/; thisNote++){
    //Calculate the note duration by taking one second divided by the note type
    // Example: quarter note = 1000/4, eightth note = 1000/8, etc
    noteDuration = 1000/tetrisDurations[thisNote];

    //Play the note
    tone(musicPin, tetrisMusic[thisNote], noteDuration);

    //Calculate the pause time (note duration plus 30%)
    pause = noteDuration*1.30;
    delay(pause);

    //Stop the tone
    noTone(musicPin);
  }
}

Credits

Brandon Michelsen

Brandon Michelsen

1 project • 7 followers
Embedded systems and robotics student at the University of Advancing Technology.

Comments