Close

(3) Getting Sign to flash with GPIO

A project log for Real-Time Audio-Controlled Neon

Building a system that encodes and reads music in MIDI format and controls the flashing of a Neon Sign with minimal latency

davidgargesdavid.garges 10/08/2018 at 00:590 Comments

The Neon artist that I was working with lived in LA and I am based out of SF (#TechieTrash) . I took a visit down to LA to grab some of her scrap tubes to light up. Conveniently, she was also working on the construction of  a custom sign that utilized the switcher and transformers from Tech 22 that I was interested in investigating for my musical interface project. Below I have included a schematic for this interface.

Below is the working video of the flasher working with the custom sign. Note that this is significantly below the 40ms switching design requirements for this projects. I was also able to measure the voltage waveform on the switching controller to verify that it would work with my Arduino's GPIO outputs.

Back at home, I was able to set up an experiment with my Arduino and the Tech 22 power supplies. By imitating the signal coming from the switcher, I could toggle the arduino's GPIO at an increasingly faster rate to observe if 40ms switching was actually possible. Below is a picture of the Tech 22 power supply that I used:

I used the following code to generate the following video:

void setup() {
  pinMode(13, OUTPUT);          // sets the digital pin 13 as output
}

void loop() {
for (int i=100; i >= 0; i--){
      digitalWrite(13, HIGH);
      delay(i);
      digitalWrite(13, LOW);
      delay(i);
   }

In conclusion, I verified that my vision of fast switching Neon was indeed possible. Next I had a little fun using the following code to control the Neon tubes with my Akai Drum Machine MIDI controller.

void setup() {
  Serial.begin(9600);
  Serial1.begin(31250);
  pinMode(13, OUTPUT);          // sets the digital pin 13 as output
  pinMode(12, OUTPUT);          // sets the digital pin 12 as output
  pinMode(11, OUTPUT);          // sets the digital pin 11 as output
}

byte Byte1;
byte Byte2;
byte Byte3;

void loop() {
  // Listening for specific Sounds
  // Kick Drum: 0x99; 0x24; 0x00->0x7F;
  //            153;  36;   0->127;
  //            0x89; 0x24; 0x00->0x7F;
  //            137;  36;   0->127;
  //
  // Snare:     0x99; 0x26; 0x00->0x7F;
  //            153;  38;   0->127;
  //            0x89; 0x26; 0x00->0x7F;
  //            137;  38;   0->127;
  //            
  // Clap:      0x99; 0x28; 0x00->0x7F;
  //            153;  40;   0->127;
  //            0x89; 0x28; 0x00->0x7F;
  //            137;  40;   0->127;  
  //
  // Open Hat:  0x99; 0x2A; 0x00->0x7F;
  //            153;  42;   0->127;
  //            0x89; 0x2A; 0x00->0x7F;
  //            137;  42;   0->127;
  //
  // Clsd Hat:  0x99; 0x2C; 0x00->0x7F;
  //            153;  44;   0->127;
  //            0x89; 0x2C; 0x00->0x7F;
  //            137;  44;   0->127;

  if (Serial1.available() > 0) {
    Byte1 = Byte2;
    Byte2 = Byte3;
    Byte3 = Serial1.read();
  
    if (Byte1 == 0x99 && Byte2 == 0x24){
      Serial.print("Kick Drum On  :");
      digitalWrite(13, LOW);        // sets the digital pin 13 off
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x89 && Byte2 == 0x24){
      Serial.print("Kick Drum Off :");
      digitalWrite(13, HIGH);       // sets the digital pin 13 on
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    
    if (Byte1 == 0x99 && Byte2 == 0x26){
      Serial.print("Snare On  :");
      digitalWrite(12, LOW);       // sets the digital pin 13 on
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x89 && Byte2 == 0x26){
      Serial.print("Snare Off :");
      digitalWrite(12, HIGH);       // sets the digital pin 13 on
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    
    if (Byte1 == 0x99 && Byte2 == 0x28){
      Serial.print("Clap On  :");
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x89 && Byte2 == 0x28){
      Serial.print("Clap Off :");
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x99 && Byte2 == 0x2A){
      Serial.print("Open Hat On  :");
      digitalWrite(11, LOW);
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x89 && Byte2 == 0x2A){
      Serial.print("Open Hat Off :");
      digitalWrite(11, HIGH);
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x99 && Byte2 == 0x2C){
      Serial.print("Closed Hat On  :");
      digitalWrite(13, LOW);
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
    if (Byte1 == 0x89 && Byte2 == 0x2C){
      Serial.print("Closed Hat Off :");
      digitalWrite(13, HIGH);
      Serial.print(Byte1);
      Serial.print(" ");
      Serial.print(Byte2);
      Serial.print(" ");
      Serial.println(Byte3);
    }
  }
}

Discussions