Saturday, August 31, 2013

Arduino powered RGB LED strip controller

One of my coworkers brought one of his creations in to show off a few weeks ago, and it sparked my creativity a bit. He had built a mobile sound system out of an Igloo Ice Cube cooler, four marine speakers, a small automotive amp, and a riding lawnmower battery. He had also upgraded the wheels to 10" pneumatic tires.

Think this, with bigger, knobbier tires, two speakers on the front, and one speaker on either side:


I had recently seen this article on Hack a Day, which lead me to this article, which lead down a rabbit hole of researching the MSGEQ7, RGB LED strip control, code examples, etc.

So I got some money from the coworker to order some parts and start development. Still have to move it to a PCB, figure out an enclosure, get a panel mount switch and pot, probably some screw terminals for power in and LED lead out, and mount everything to the cooler.

Ran into a couple challenges, mainly related to noise from the PWM interfering with the audio ground, causing a feedback loop which kept one of the LEDs lit. Ended up eliminating that by altering the timers on the Arduino to move the PWM frequency out of the range of audible frequencies. Also learned a bit about ground loops and how to eliminate them.

From the youtube video, a description on what everything does:

Arduino controlling an analog 5050 RGB LED strip, using one button and one pot for manual control, and a MSGEQ7 to input the audio. Controller has 7 modes, which are cycled through by pressing the one button.

1) Audio visualization. Uses audio input from a headphone jack to change the value of the red, green and blue LEDs based upon low, mid, and high EQ values.
2) Solid color. (2:25) Uses pot to cycle through colors, varying RGB values based upon position.
3) Pulse. (2:47) Pulses last color chosen during setting 2, at a speed based upon pot position.
4) Color cycle. (3:12) Automatically cycles between red, green, and blue, and all the colors in between. Speed of cycle is based upon pot position.
5) Random color cycle. (3:35) "Random" values of RGB are chosen, then transitioned to.
6) Campfire mode. (3:53) Color and flicker programmed to simulate campfire. I still think it's a little too orange, but still tweaking.
7) White. (4:05) Sets red, green and blue to the same value to generate "white" light. Brightness is set by pot position.
8) Off. (4:22) All LEDs set to zero.

Once the button is pushed again, the controller cycles back to the first option.


A bad fritzing diagram of how everything is hooked up. Links to sources for each part are in the code block below.


The single RGB LED represents the strip, source voltage to the top rail is 12v, bottom rail is 5v. 


  /*   
   RGB LED music controller  
   8 modes: music reaction, color select, color pulse, R>G>B cycle, random cycle, campfire simulation, all white, and off  
   By Russell Milling 2013-08-31  
     
   Large portions of code, wiring diagrams, and other help borrowed from:  
   Markus Ulfberg   
   http://genericnerd.blogspot.com/2011/12/arduino-mood-light-controller-v3.html  
   n00bsys0p   
   http://www.n00bsys0p.co.uk/blog/2012/07/09/arduinomsgeq7-audio-spectrum-led-display  
   J. Skoba   
   http://nuewire.com/info-archive/msgeq7-by-j-skoba/  
   Tyler Cooper   
   http://learn.adafruit.com/rgb-led-strips  
   Those who edit articles on the Arduino Playground   
   http://playground.arduino.cc/Main/TimerPWMCheatsheet  
   The DIY & Hobbies forum on SomethingAwful   
   http://forums.somethingawful.com/showthread.php?threadid=2734977&pagenumber=223#post418931935  
     
     
     
   Thanks to: Ladyada, Tom Igoe and   
   everyone at the Arduino forum for excellent   
   tutorials and everyday help.   
    
  */  
    
  /* stuff to smooth out the pot readings  
    
    Define the number of samples to keep track of. The higher the number,  
    the more the readings will be smoothed, but the slower the output will  
    respond to the input. Using a constant rather than a normal variable lets  
    use this value to determine the size of the readings array.  
  */  
    
    
  const int numReadings = 10;  
    
  int readings[numReadings];   // the readings from the analog input  
  int index = 0;         // the index of the current reading  
  int total = 0;         // the running total  
  int average = 0;        // the average  
    
  // set the ledPins  
  int ledRed = 9;  
  int ledGreen = 10;  
  int ledBlue = 11;  
    
  // color selector pin  
  int potPin = 0;  
     
  // lightMode selector switch pin  
  int switchPin = 2;  
   
  // light mode variable  
  // initial value 0 = music  
  int lightMode = 0;  
    
  // LED Power variables  
  byte redPwr = 0;  
  byte greenPwr = 0;  
  byte bluePwr = 0;  
  byte ledPwr = 0;  
    
  // Variables for lightMode 2  
  // variables for keeping pulse color  
  byte redPulse;  
  byte greenPulse;  
  byte bluePulse;  
  int pulseSpeed;   
    
  // Set pulse to down initially  
  byte pulse = 0;  
    
  // floating variables needed to be able to pulse a fixed color   
  float redFloat;  
  float greenFloat;  
  float blueFloat;  
    
  // the amount R,G & B should step up/down to display an fixed color  
  float redKoff;  
  float greenKoff;  
  float blueKoff;  
    
  // Variables for lightMode 3  
  // set the initial random colors  
  byte redNew = random(255);  
  byte greenNew = random(255);  
  byte blueNew = random(255);  
    
  // Variables for cycleColor  
  int truColor = 0;  
    
  // misc interface variables  
  // potVal store the value of the potentiometer for various needs   
  int potVal;  
  // value from the button (debounce)  
  int switchVal;  
  int switchVal2;  
  // buttonState registers if the button has changed  
  int buttonState;  
    
  // MSGEQ7 stuff for music  
    
  int analogPin = 3; // MSGEQ7 OUT  
  int strobePin = 4; // MSGEQ7 STROBE  
  int resetPin = 7; // MSGEQ7 RESET  
  int spectrumValue[7]; // store the 7 eq band values  
     
  // MSGEQ7 OUT pin produces values around 50-80  
  // when there is no input, so use this value to  
  // filter out a lot of the chaff.  
  int filterValue = 80;  
    
  // variable to control the max intensity of the LEDs when in music mode  
  int filterMax = 255;  
    
    
  void setup()  
  {  
   pinMode(ledRed, OUTPUT);  
   pinMode(ledGreen, OUTPUT);  
   pinMode(ledBlue, OUTPUT);  
     
   pinMode(potPin, INPUT);  
     
   pinMode(switchPin, INPUT);  
   buttonState = digitalRead(switchPin);   
     
     
     
   // serial for debugging purposes only  
   // Serial.begin(9600);  
     
   // pot smoothing  
   for (int thisReading = 0; thisReading < numReadings; thisReading++)  
     readings[thisReading] = 0;   
       
     // Read from MSGEQ7 OUT  
   pinMode(analogPin, INPUT);  
   // Write to MSGEQ7 STROBE and RESET  
   pinMode(strobePin, OUTPUT);  
   pinMode(resetPin, OUTPUT);  
     
   // Set analogPin's reference voltage  
   analogReference(DEFAULT); // 5V  
     
   // Set startup values for pins  
   digitalWrite(resetPin, LOW);  
   digitalWrite(strobePin, HIGH);  
    
   // set the Arduino timers to crazyfast values for pins 3, 9, 10, and 11 so that PWM doesn't cause audible hum or feedback in the audio circuit.   
   //If changing code to use a second LED strip on the other 3 PWM pins, make sure to set TCCR0B as well, but be mindful that it will effect system timer values  
   // such as delay(), millis(), micros(), etc  
   // See: http://playground.arduino.cc/Main/TimerPWMCheatsheet for more information  
   TCCR1B = TCCR1B & 0b11111000 | 0x01;  
   TCCR2B = TCCR2B & 0b11111000 | 0x01;  
  }  
    
  void loop()  
  {  
   switchVal = digitalRead(switchPin);   // read input value and store it in val  
   delay(10);             // 10 milliseconds is a good amount of time  
      
   switchVal2 = digitalRead(switchPin);   // read the input again to check for bounces  
   if (switchVal == switchVal2) {         // make sure we got 2 consistant readings!  
    if (switchVal != buttonState) {     // the button state has changed!  
     if (switchVal == LOW) {        // check if the button is pressed  
      switch (lightMode) {     // light is initially in music react mode  
       case 0:  
        lightMode = 1;      // light is on and responds to pot to choose color  
        break;   
       case 1:  
        lightMode = 2;      // light pulsates in the latest color from pot  
        break;   
       case 2:     
        lightMode = 3;      // light cycles thru colors  
        break;  
       case 3:  
        lightMode = 4;      // light changes randomly  
        break;  
       case 4:  
        lightMode = 5;      // simulated fire  
        break;   
       case 5:     
        lightMode = 6;       // all white      
        break;   
       case 6:  
        lightMode = 7;      // lights off  
        break;  
       case 7:  
        lightMode = 0;      // music react  
        break;                       
      } // END switch (lightMode)    
     } // END if (switchVal == LOW)  
    } // END if (switchVal != buttonState)   
       
    buttonState = switchVal;         // save the new state in our variable  
   } // END if (switchVal == switchVal2)  
    
     
   // Debug  
   //Serial.print("lightMode: ");  
   //Serial.println(lightMode);  
     
     
   switch (lightMode) {  
    case 0:  
     musicEQ();  
     break;  
    case 1:  
     colorControl();  
     break;  
    case 2:  
     pulsateColor();  
     break;  
    case 3:   
     cycleColor();  
     break;  
    case 4:  
     randomColor();  
     break;  
    case 5:  
     lightMyFire();  
     break;   
    case 6:  
     allWhite();  
     break;  
    case 7:  
     lightsOff();  
     break;  
   }  
    
  } // END loop()  
    
    
  // lightMode 7  
  void lightsOff() {  
   redPwr = 0;  
   greenPwr = 0;  
   bluePwr = 0;  
   colorDisplay();  
  }  
    
  // lightMode 1   
  void colorControl() {  
    
    // read the potentiometer position  
    getPot();  
    potVal = average;   
     
   // RED > ORANGE > YELLOW  
    if (potVal > 0 && potVal < 170) {  
     redPwr = 255;  
     bluePwr = 0;  
     greenPwr = map(potVal, 0, 170, 0, 255);  
    }  
     
    // YELLOW > LIME?? > GREEN   
    if (potVal > 170 && potVal < 341) {  
     greenPwr = 255;  
     bluePwr = 0;  
     redPwr = map(potVal, 341, 170, 0, 255);  
    }  
    
    // GREEN > TURQOUISE  
    if (potVal > 341 && potVal < 511) {  
     greenPwr = 255;  
     redPwr = 0;  
     bluePwr = map(potVal, 341, 511, 0, 255);  
    }  
     
    // TURQOUISE > BLUE   
    if (potVal > 511 && potVal < 682) {  
     bluePwr = 255;  
     redPwr = 0;  
     greenPwr = map(potVal, 682, 511, 0, 255);  
    }  
     
    // BLUE > PURPLE   
    if (potVal > 682 && potVal < 852) {  
     bluePwr = 255;  
     greenPwr = 0;  
     redPwr = map(potVal, 682, 852, 0, 255);  
    }  
     
    // PURPLE > RED  
    if (potVal > 852 && potVal < 1023) {  
     redPwr = 255;  
     greenPwr = 0;  
     bluePwr = map(potVal, 1023, 852, 0, 255);  
    }   
      
    redFloat = float(redPwr);  
    greenFloat = float(greenPwr);  
    blueFloat = float(bluePwr);  
      
    redKoff = redFloat / 255;  
    greenKoff = greenFloat / 255;  
    blueKoff = blueFloat / 255;  
      
    redPulse = redPwr;  
    greenPulse = greenPwr;  
    bluePulse = bluePwr;   
      
   /*  
   // Debug   
   Serial.print("redFLoat: ");  
   Serial.print(redFloat, DEC);  
   Serial.print(" redPwr: ");  
   Serial.print(redPwr, DEC);  
   Serial.print(" greenFloat: ");  
   Serial.print(greenFloat, DEC);  
   Serial.print(" greenPwr: ");  
   Serial.print(greenPwr, DEC);  
   Serial.print(" blueFloat: ");  
   Serial.print(blueFloat, DEC);  
   Serial.print(" bluePwr: ");  
   Serial.println(bluePwr, DEC);  
   // End debug  
   */  
     
   // Display colors   
   colorDisplay();  
  }      
    
  // lightMode 2  
  void pulsateColor() {  
     
    // get colors from colorControl  
    redPwr = int(redFloat);  
    greenPwr = int(greenFloat);  
    bluePwr = int(blueFloat);  
       
    // Read speed from potentiometer   
    getPot();  
    potVal = average;   
    pulseSpeed = map(potVal, 0, 1023, 0, 200);  
     
    //display the colors  
    colorDisplay();  
      
    // set speed of change  
    delay(pulseSpeed);  
      
    // pulse down  
    if (pulse == 0) {  
     if (redFloat > 10) {  
      redFloat = redFloat - redKoff;  
     }   
     if (greenFloat > 10) {  
      greenFloat = greenFloat - greenKoff;  
     }   
     if (blueFloat > 10) {  
      blueFloat = blueFloat - blueKoff;  
     }   
    
    // If all xFloat match 10 get pulse up  
    if (byte(redFloat) <= 10) {  
     if (byte(greenFloat) <= 10) {  
     if (byte(blueFloat) <= 10) {  
      pulse = 1;  
     }  
     }  
    }  
   }  
   // Pulse up  
   if (pulse == 1) {  
    if (redFloat < redPulse) {  
     redFloat = redFloat + redKoff;  
    }   
    if (greenFloat < greenPulse) {  
     greenFloat = greenFloat + greenKoff;  
    }   
    if (blueFloat < bluePulse) {  
     blueFloat = blueFloat + blueKoff;  
    }  
    // If all Pwr match Pulse get pulse down  
     
    if (byte(redFloat) == redPulse) {  
     if (byte(greenFloat) == greenPulse) {  
     if (byte(blueFloat) == bluePulse) {  
      pulse = 0;  
     }  
     }  
    }  
   }  
     
   /*  
   // Debug   
   Serial.print("redFloat: ");  
   Serial.print(redFloat, DEC);  
   Serial.print(" redPulse: ");  
   Serial.print(redPulse, DEC);  
   Serial.print(" greenFloat: ");  
   Serial.print(greenFloat, DEC);  
   Serial.print(" greenPulse: ");  
   Serial.print(greenPulse, DEC);  
   Serial.print(" blueFloat: ");  
   Serial.print(blueFloat, DEC);  
   Serial.print(" bluePulse: ");  
   Serial.print(bluePulse, DEC);  
   Serial.print(" pulse: ");  
   Serial.println(pulse, DEC);  
   // End debug  
   */  
     
  } // pulsateColor END   
    
  // lightMode 3  
  void cycleColor() {  // Cycles through colors  
    
   switch(truColor) {  
   // RED > ORANGE > YELLOW    
    case 0:  
     redPwr = 255;  
     bluePwr = 0;  
     greenPwr++;  
     if (greenPwr > 254) {  
      truColor = 1;  
     }  
     break;  
      
    // YELLOW > LIME?? > GREEN   
    case 1:  
     greenPwr = 255;  
     bluePwr = 0;  
     redPwr--;  
     if (redPwr < 1) {  
      truColor = 2;  
     }  
     break;  
    
    // GREEN > TURQOUISE  
    case 2:  
     greenPwr = 255;  
     bluePwr++;  
     redPwr = 0;  
     if (bluePwr > 254) {  
      truColor = 3;  
     }    
    break;  
      
    // TURQOUISE > BLUE   
    case 3:  
     greenPwr--;  
     bluePwr = 255;  
     redPwr = 0;  
     if (greenPwr < 1) {  
      truColor = 4;  
     }  
     break;  
       
    // BLUE > PURPLE   
    case 4:  
     greenPwr = 0;  
     bluePwr = 255;  
     redPwr++;  
     if (redPwr > 254) {  
      truColor = 5;  
     }  
     break;  
       
    // PURPLE > RED  
    case 5:  
     greenPwr = 0;  
     bluePwr--;  
     redPwr = 255;  
     if (bluePwr < 1) {  
      truColor = 0;  
     }    
     break;  
   }  
   // START SPEED   
   getPot();  
   potVal = average;   
   pulseSpeed = map(potVal, 0, 1023, 0, 200);  
     
   //display the colors  
   colorDisplay();  
   // set speed of change  
   delay(pulseSpeed);  
   // END SPEED  
     
  } // END cycleColor   
    
    
  // lightMode 4   
  void randomColor() {   // randomize colorNew and step colorPwr to it  
                 
   if (redPwr > redNew) {  
    redPwr--;  
   }   
   if (redPwr < redNew) {  
    redPwr++;  
   }  
   if (greenPwr > greenNew) {  
    greenPwr--;  
   }   
   if (greenPwr < greenNew) {  
    greenPwr++;  
   }  
   if (bluePwr > blueNew) {  
    bluePwr--;  
   }   
   if (bluePwr < blueNew) {  
    bluePwr++;  
   }  
    
  // If all Pwr match New get new colors  
     
   if (redPwr == redNew) {  
    if (greenPwr == greenNew) {  
    if (bluePwr == blueNew) {  
     redNew = random(254);  
     greenNew = random(254);  
     blueNew = random(254);  
    }  
    }  
   }  
     
   getPot();  
   potVal = average;   
   pulseSpeed = map(potVal, 0, 1023, 0, 200);  
     
   //display the colors  
   colorDisplay();  
   // set speed of change  
   delay(pulseSpeed);  
    
  } // END randomColor   
    
  // lightMode 5  
  void lightMyFire() {  
     
   // Flicker will determine how often a fast flare will occur  
   int flicker;  
    
   // set flicker randomness  
   flicker = random(1800);   
    
   // Set random colors,   
   // constrain green to red and blue to green  
   // in order to stay within a red, blue, white spectrum  
   redPwr = random(220, 240);  
   greenPwr = random(20, 40);  
   // when flicker occur, the colors shine brighter  
   // adding blue creates a white shine   
   if (flicker > 1750) {  
    redPwr = 254;  
    greenPwr = random(60, 80);   
    bluePwr = random(10, 40);    
   } else {  
    bluePwr = 0;  
   }  
     
   // display Colors  
   colorDisplay();  
     
   // Set speed of fire  
   delay(80);   
    
  } // END lightMyFire  
    
  // lightMode 6  
  void allWhite() {  
      
   // Smoothing out the pot readings. Will replace later with getPot()  
     
   getPot();  
     
   // map the smoothed pot value to LED pwm  
   ledPwr = map(average, 0, 1023, 0, 255);  
     
   redPwr = ledPwr;  
   greenPwr = ledPwr;  
   bluePwr = ledPwr;  
     
   colorDisplay();  
  } // End allWhite  
    
  // Begin lightMode 0   
  void musicEQ() {  
     
   getPot();  
     
   filterMax = map(average, 0, 1023, 0, 255);  
     
   // Set reset pin low to enable strobe  
   digitalWrite(resetPin, HIGH);  
   digitalWrite(resetPin, LOW);  
     
   // Get all 7 spectrum values from the MSGEQ7  
   for (int i = 0; i < 7; i++)  
   {  
    digitalWrite(strobePin, LOW);  
    delayMicroseconds(30); // Allow output to settle  
     
    spectrumValue[i] = analogRead(analogPin);  
     
    // Constrain any value above 1023 or below filterValue  
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);  
     
    // Remap the value to a number between 0 and 255  
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, filterMax);  
     
    // Remove serial stuff after debugging  
    //Serial.print(spectrumValue[i]);  
    //Serial.print(" ");  
     
    digitalWrite(strobePin, HIGH);  
    }  
     
    //Serial.println();  
       
    /* Spectrum Value Frequencies:  
     0: 63 Hz  
     1: 160 Hz  
     2: 400 Hz  
     3: 1000 Hz  
     4: 2500 Hz  
     5: 6250 Hz  
     6: 16000 Hz  
       
     1, 4, and 6 seem to offer best combination using only 3 LEDs  
     If using 6 LEDs, 1-6 or 1-3 and 4-6 depending on music.  
    */  
      
   redPwr = spectrumValue[1];  
   greenPwr = spectrumValue[4];  
   bluePwr = spectrumValue[6];  
     
   colorDisplay();  
  }  
    
  // Displays the colors when called from other functions  
  void colorDisplay() {  
   analogWrite(ledRed, redPwr);  
   analogWrite(ledGreen, greenPwr);  
   analogWrite(ledBlue, bluePwr);  
  }  
    
    
  // Smooths out the pot readings.   
  void getPot() {  
   // subtract the last reading:  
   total= total - readings[index];       
   // read from the sensor:   
   readings[index] = analogRead(potPin);   
   // add the reading to the total:  
   total= total + readings[index];      
   // advance to the next position in the array:   
   index = index + 1;            
    
   // if we're at the end of the array...  
   if (index >= numReadings)         
    // ...wrap around to the beginning:   
    index = 0;                
    
   // calculate the average:  
   average = total / numReadings;       
   // send it to the computer as ASCII digits  
   // Serial.println(average);    
   delay(1);    // delay in between reads for stability        
  }  

A partial parts list for what I used other than the Arduino:

220k ohm resistor
http://www.taydaelectronics.com/resistors/1-4w-metal-film-resistors/220k-ohm-1-4w-1-metal-film-resistor.html
.01uf capacitor
http://www.taydaelectronics.com/capacitors/ceramic-disc-capacitors/10-x-0-01uf-50v-ceramic-disc-capacitor-pkg-of-10.html
(2) .1uf capacitor
http://www.taydaelectronics.com/capacitors/ceramic-disc-capacitors/10-x-0-1uf-50v-ceramic-disc-capacitor-pkg-of-10.html
33pf capacitor
http://www.taydaelectronics.com/capacitors/ceramic-disc-capacitors/10-x-33pf-50v-ceramic-disc-capacitor-pkg-of-10.html

3x N channel mosfets:
http://www.mouser.com/ProductDetail/STMicroelectronics/STP16NF06L/?qs=RC432zO33OqodrhO5g7gPg%3d%3d
2x
Headphone jack
http://www.mouser.com/ProductDetail/Kobiconn/161-3402-E/?qs=%2fha2pyFaduiyB%252bLCpU7TZoJ3cfVHPgazskZ0wf2sV%252bg%3d
A push button. Can be as simple as this, or as fancy as you want. Make sure to get normally open, single pole, single throw in a panel mount package.
http://www.taydaelectronics.com/electromechanical/switches-key-pad/push-button/pb-11d02-push-button-panel-mount-spst-no-pb-11d02-th1r00.html
A 1K ohm linear potentiometer. Again, get a panel mount part, and you can go fancy or simple with a knob for it if you want.
http://www.taydaelectronics.com/potentiometer-variable-resistors/rotary-potentiometer/linear/1k-ohm-linear-taper-potentiometer-with-solder-lugs.html
http://www.ebay.com/sch/i.html?_odkw=1k+linear+potentiometer&_fspt=1&_sop=12&_osacat=0&_mPrRngCbx=1&_trksid=p2045573.m570.l1313.TR12.TRC2.A0.Xpotentiometer+knob&_nkw=potentiometer+knob&_sacat=0&_from=R40

RGB LED strip. This is the one I ordered. Comes with a controller, but not a power brick. It's not hard to find a 12v power brick that you can use with these laying around with old electronics.
http://www.ebay.com/itm/290954092203?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

MSGEQ7, which is the chip that takes the audio in and turns it into something the microcontroller can use:
http://www.ebay.com/sch/items/?_nkw=msgeq7&_sacat=&_ex_kw=&_mPrRngCbx=1&_udlo=&_udhi=&_sop=12&_fpos=&_fspt=1&_sadis=&LH_CAds=

53 comments:

  1. Christian from youtube here ... i got the mega and a mega shield and i hooked it up on the same way as perscribed above but i dont seem to be getting any feedback from the led on the board. Also where do i actually plug in the LED strip. thank you again for your help

    ReplyDelete
  2. dear rusell
    transistor can be replaced by some more economical?
    I did not connect more than five meters of LED `s

    ReplyDelete
  3. I'd stick with the beefier N-channel mosfets. It's only $3 worth of fets.

    ReplyDelete
  4. Can i get your code without the numbers in front of every line ?

    ReplyDelete
    Replies
    1. i quit the number, if you want, i can send the arduino proyect. sory for my englesh.

      Delete
  5. My name is Mike and i am wholesaler, here need to ask you people that is led led lighting strip effective to start business with?

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. You want the second strip to be controlled separately from the first, with just the musicEQ and cycleColor modes?

      Delete
    2. This comment has been removed by the author.

      Delete
    3. This comment has been removed by the author.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Hello Russel, great work! I had slight confusion, with the C3 and C4 capacitors, are they intertwined together? That's something I wanted to make sure before I tried my circuit out. Thanks!

    ReplyDelete
    Replies
    1. Yeah, looking at it now, it is a little confusing. C3 connects from pin 6 on the MSGEQ7 to ground, and C4 connects from pin 5 to the + line on the headphone jack. They're not connected together at all.

      Delete
  10. Hey good job! I just had a question, the music mode on my circuit is not working. Any suggestions on how to troubleshoot it? Also for the C1 capacitor I have it hooked up to the 5V line and not 6.3V would that be an issue? Thanks

    ReplyDelete
    Replies
    1. Huh. I hadn't noticed the 6.3V in the drawing. I'm not sure where that came from, but it wasn't intentional.

      To troubleshoot the music mode, modify the sketch here: http://nuewire.com/info-archive/msgeq7-by-j-skoba/ to use the pins you have your MSGEQ7 hooked up to, and see if you're getting changing values on the serial output. That's where I'd start.

      Delete
  11. hello
    I want to know what is the type of resistance that is connected to potentiometer as there is nothing noted and I am a novice in this area thank you

    ReplyDelete
    Replies
    1. Doesn't really matter. I think I used a 10k.

      Delete
  12. This is very helpful website.I have learn many thing from this website. Thanks for share it
    Arduino

    ReplyDelete
  13. Cool project, but you should really do a video of the finished product in action.
    Thanks for crediting and linking.

    ReplyDelete
  14. Any chance of getting code that actually works? Surely this isnt a copy and paste of what you actually used, its raked with errors?

    ReplyDelete
    Replies
    1. No, it's what I actually used, and it works.

      Delete
  15. Sorry if I sounded harsh, I was just up all night trying to get your code to compile... There is obviously something that I don't understand going on.

    ReplyDelete
    Replies
    1. No problem. What errors are you getting?

      Delete
    2. Thanks Russell, tbh the error message is too long to post here. I could email it but would probably be quicker to explain. sketch_mar18a.ino:4:30: error: invalid digit "8" in octal constant
      sketch_mar18a.ino:2:1: error: expected unqualified-id before numeric constant
      sketch_mar18a.ino:38:1: error: expected unqualified-id before numeric constant

      And then it carries on saying the line above, but going up in numbers. Is this something to do with leaving the numbers infront of the lines? I honestly thought that was ok. Please forgive my ignorance if that is the problem!
      Error compiling.

      Delete
    3. Oh, yeah, you've got to clear the numbers. I'll see about editing the post to fix that.

      Delete
    4. Ok, check the post now, I've removed the line numbers.

      Delete
    5. That's amazingly helpful of you, thank Russell! As you can tell I really am a novice. I just tried to verify the amended code and still received some error messages.


      Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"

      The sketch name had to be modified. Sketch names can only consist
      of ASCII characters and numbers (but cannot start with a number).
      They should also be less than 64 characters long.


      sketch_mar18b_Rus_Edit.ino:4:28: error: invalid digit "8" in octal constant

      sketch_mar18b_Rus_Edit.ino:2:1: error: 'RGB' does not name a type

      sketch_mar18b_Rus_Edit.ino:39:16: error: 'numReadings' was not declared in this scope

      sketch_mar18b_Rus_Edit.ino: In function 'void setup()':

      sketch_mar18b_Rus_Edit.ino:136:44: error: 'numReadings' was not declared in this scope

      sketch_mar18b_Rus_Edit.ino:137:6: error: 'readings' was not declared in this scope

      sketch_mar18b_Rus_Edit.ino: In function 'void getPot()':

      sketch_mar18b_Rus_Edit.ino:647:19: error: 'readings' was not declared in this scope

      sketch_mar18b_Rus_Edit.ino:656:17: error: 'numReadings' was not declared in this scope

      sketch_mar18b_Rus_Edit.ino:661:22: error: 'numReadings' was not declared in this scope

      Error compiling.

      Would these be simply to do with the fact the circuit isn't actually connected at this point?

      Anyways, I am getting the final components for the build tomorrow, what I will do to make things easier is a post on my own blog about where I am at, with photo's etc. I really do appreciate your help Russell. If I get this working I will happily reimburse you for your guidance!

      Delete
    6. It compiles fine for me in Arduino 1.0.5. I'll install 1.6 and test it when I get home later. I think there have been some minor changes that may be throwing errors for you.

      Delete
  16. Hi Russell, if it is going to be easier I will just install Ard 1.0.5, will save us both time! Unortunately I cant get a hold of the extra resistors till Monday. Hopefully once that is all sorted it will be plain sailing! Cheers.

    ReplyDelete
    Replies
    1. Just did a test compile in 1.6.1, and it worked fine. Are you sure you're copying the entire code block?

      Delete
  17. Really bizarre, sorry Russell this comment only just showed up for me. But if it worked fine for you first time round then I guess I didn't. I am still missing the TRS input and secondary resistor which I shall get tomorrow. Did you say it was a 10k? im really no good with all these colour strip systems on the caps and resistors. Cheers.

    ReplyDelete
  18. Hi Russell, just to let you know it as obviously my error that was causing the problem, it has just compiled for me perfectly in 1.6. Just about to put together a blog post with a bunch of photos of where the board is at. I think it is good to go except for my lack of TRS and connection for my button, as I think I need to soldier that... I connected the strip and power a tiny bit different as I am just using the external brick that came with the LEDs to power it. The photos will explain better in a few hours. But yeah, you code is fine, so my apologies.

    ReplyDelete
  19. Here is the Blog post (first post) with photos of where I am at. Please don't feel you have to read it all, a lot is for the benefit of uni. If you could look through the pictures and make sure everything is in order that would be great. I know I still need to build in the TRS circuit and get the 10k resistor in. I just need clarification that the way I have power routing set up will work? That is the 12v brock that came with the LED's, just stripped with wires attached for Breadboard work.. I think this should work right?

    http://allabouthonours.blogspot.co.uk/

    ReplyDelete
    Replies
    1. Looks good, glad to see that my writeup has helped.

      You can actually use that 12v brick to power the Arduino as well, just tie it into the "Vin" pin on the board. It's got a regulator that'll knock it down to the 5v that the Arduino and MSGEQ7 chip need.

      For reference: http://arduino.cc/en/main/arduinoBoardUno

      "VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin."

      Delete
    2. I have fixed the mistake I had made about the capacitors being interlinked having read through some of the comments above... I'll get there!

      Delete
    3. Ah thats amazing, that should actually help me a lot in making a little box to house it in for the back of the diffuser. I really can;t wait to get the TRS now. Roll on Monday. Cheers

      Delete
  20. Hi Russell, got all the parts now but unfortunately the circuit didnt work, I must have misunderstood something. Could you possibly take some photos of the breadboard setup you have so I can make sure Im getting it right? Im also rebuilding the circuit as we speak taking a photo at every stage so you can see precisely where I may have gone wrong. Cheers

    ReplyDelete
    Replies
    1. Did none of it work, or just the audio portions?

      Delete
    2. Nope I didn't get any power through the circuit. I have stripped it all back and started from scratch this time with a detailed tut of what I have done... I have also replaced the Caps, Resistors and MOSFETS with fresh ones to make sure everything is all good.

      Hopefully by the end of this we can get a really good guide on the go. So far I have just done the Breadboard step by step. I have a meeting now, I will do the Ard side of it when I get back. It's the top post, cheers.

      http://allabouthonours.blogspot.co.uk/

      Delete
  21. The second post is up now Russell. Obviously the way blogger work the arduino section is now above the breadboard, just incase you haven't already seen that. As far as I know, all the connection points are spot on. Cheers.

    ReplyDelete
  22. Hi Russell, Just thought I should let you know that I managed to get everything working. I actually just went back to the simpler Audio reactive only circuit and swapped the pins back to the way J.Skoba had it with the res and cap routed directly to live and ground. really shouldnt have made a difference, but it did for whatever reason.. Perhaps a faulty pin on the arduino. I also swapped ou the MSGEQ7 for my other one. I will reverse engineer it to find out at a later date.

    Anyway, thanks for your pointers along the way, all the best.

    ReplyDelete
  23. Hi Russell, I am currently populating my bibliography for my dissertation, I was wondering if I could ask your second name? If you would rather not say that is fine obviously, I can just use your first name. Thanks in advance.

    Mike

    ReplyDelete
  24. Russell,

    I built one of these using an Arduino Uno and the music mode worked BEAUTIFULLY. However, i built another using an Arduino Pro Mini and the results are strobey– like the intensity of light for each change drops off to zero after every change. In between every note the strip goes dark and the result makes me feel like I'm gonna have a seizure.

    I've tried changing different values in your code to no avail. I'm beginning to suspect it may have something to do with this bit

    TCCR1B = TCCR1B & 0b11111000 | 0x01;
    TCCR2B = TCCR2B & 0b11111000 | 0x01;

    not working in the Pro Mini.

    Any idea what could be causing this and how I can fix it?

    ReplyDelete
    Replies
    1. Are you using an 8mhz/3.3v or 16mhz/5v Pro Mini?

      Delete
    2. It's a 5v, 16mhz pro mini.

      I just tried it with a cheap Chinese "Nano" knockoff, which is working like the Uno does. Strange.

      Delete
    3. Here's a video of it working fine on the Uno
      https://www.youtube.com/watch?v=w_T9I8b7o2E

      Here's a video of it dropping off to dark on the Pro Mini
      https://www.youtube.com/watch?v=Pk3nW8_qZO8

      Delete
    4. btw, thought you might like to see a shot of it all packaged up :)

      https://scontent-lax1-1.xx.fbcdn.net/hphotos-xat1/v/t1.0-9/11825708_10154106048978136_5735971412420633680_n.jpg?oh=5cfb8476a2b988b02ecd6135db356eaa&oe=564F5350

      Delete
  25. Thanks in favor of sharing such a fastidious idea, piece of writing is nice, thats why i have read it completely.INDOOR LED STRIP LIGHTS

    ReplyDelete
  26. Hey Russel
    Will this work with a 16x16 Adafruit Neopixel LED Matris??

    Thanks

    ReplyDelete
  27. Hi Dear,

    I Like Your Blog Very Much. I see Daily Your Blog, is A Very Useful For me.

    Wholesale LED strip lighting in 12V and 24V. white led lighting strips Buy color changing RGB tape lights, single color LED light strip kits. We also make custom LED tape lights.

    Visit Now:- https://www.wholesale-leds.com/

    ReplyDelete
  28. Online Gambling: How to Play at a Casino - Dr. Maryland
    The online gambling market 순천 출장샵 is 양주 출장샵 growing 김포 출장샵 fast. A real-time 과천 출장안마 gambling experience 성남 출장마사지 in the form of blackjack. Players can play online slots, table games,

    ReplyDelete