Preface: As I am continually working on the synchronization routines for the LEDs, even while I'm writing this Instructable, there are some last minute changes that I will add to the end in Step 13 "Last Minute Changes".
Videos: The first one demonstrates the LEDs reacting to different types of music. The second one shows the difference between the code that turns on each LED individually and the code that turns the LEDs on in groups of two.
3/6/16 added one more video, after adding 10 lasers to the show

After completing my "Simple FC-04 Sound Sensor Demo" Instructable I had a feeling that I could do more with that module than meets the eye. So I kept playing with it to see just how far I could push it. What I ended up with is my "light board" which has ten light tubes and twenty LEDs that synchronize to your favorite music.

This project is NOT for the faint at heart. Getting the LEDs to synchronize to the music with an inexpensive FC-04 sound sensor took a lot of play time. And to duplicate my results will also take a lot of play time. But, the more you play with this the more you start to understand the relationship between all the different pieces of the puzzle that make it work.

It all boils down to the key features listed below and understanding how they interact to affect the overall functionality of the sketch. I'll break these down for you in the next few steps;

1. splitting the "ON" and "OFF" functions into separate sections

2. running the "ON" section multiple times before running the "OFF" section

3. running four different OFF patterns at different times

4. using an average of the sensor value

5. using ranges based on the average sensor value to turn on specific LEDs

6. the FC-S04's "sensitivity" potentiometer (POT) plays a huge role in this

7. a tiny little ceramic capacitor

Step 1: Key Items #1. Splitting the ON and OFF Functions

1. splitting the "ON" and "OFF" functions into separate sections

Placing the on and off functions in their own sections within the script was a big piece of this puzzle for me. Prior to doing so I was close to getting the LEDs to respond the way I wanted but it still wasn't right.

I now have all of the functions to turn the LEDs ON grouped together under the "ledsON:" label. And all of the functions to turn the LEDs back OFF again are together under the "ledsOFF:" label.

This also allowed me to cycle through the "ON" section of the code multiple times before moving to the "OFF" section. This allows the program to pick up more of the changes in the average sensor value. But you have to take into account that the more times you run through the ON section the slower the program gets to the OFF sections.

Let's talk about these "labeled" sections in this sketch. If you haven't used a label before, don't panic. Think of a label as nothing more than a bookmark in your code. And creating a label couldn't be easier -

LABEL1: (note the colon, you DO NOT add a semicolon at the end of a label)

That's it, we just created a label (bookmark) called "LABEL1". You can now go directly to the functions under LABEL1: from anywhere in your script. Labels are very useful especially when combined with other functions such as "if" statements.

Here's a quick example:

In the following example we hope that "x" is always equal to 10 otherwise it looks like we're going to launch a nuclear missile!


if (x = 10 goto LABEL1); // (note: DO NOT use the colon at the end of a label name when calling it)

// prepare missile for launch

digitalWrite(Safety, LOW); // there's a safety switch? Apparently we just turned it off!

digitalWrite(Launch, HIGH); // launch the missile - bummer


serial.Println("X was equal to 10 ");

serial.Println("remove head from between knees")


In the above example so long as "x" is equal to 10 the program will skip over everything including "// prepare missile for launch" and go directly to the code under LABEL1.

But there's a problem, the program will continue reading the code that comes after LABEL1, including the additional code that's later in the script which preps and launches the backup Tomahawk missiles. It is common when using labels to have one named END: at the end of your sketch. The END: label allows you to get the heck out of dodge. To stop the program from launching the Tomahawks when it gets to that part of the code, we stop the program from getting to that part of the code! If we were to add

goto END;

under the last serial.Println line above the sketch will go directly to the END and skip launching those Tomahawks as well.

Step 2: Key Items #2. Running the "ON" Section Multiple Times

2. running the "ON" section multiple times before running the "OFF" section

As I mentioned in Step 1, splitting the on and off functions into their own sections within the script was a big piece of the puzzle with this project. By splitting them up I could now cycle through the ON functions multiple times before going anywhere near the OFF functions. This accomplished two things for me. 1. It stops the LEDs from flickering on and off so fast that you get dizzy looking at it. 2. The LEDs synchronize much better because each LED has a chance to read the sensor's value multiple times to determine if it should turn ON or not.

An "if" statement and a variable named "count" control how often the ON statements are read before going to the OFF statements. And each of the OFF statements is only read once before the script cycles through the ON statements again.

So the entire script begins with a labeled section named "CheckCount".

CheckCount: // this is the "label"

if (count >1100) goto ledsOFF; // how many times to run the ON statements before going to the OFF section

That's not a typo, the ON statements are read 1,101 times before any LEDs are turned off. But watch one of the videos and you'll see how fast that happens.

count = (count +1); // each time the program cycles through the ON statements it increases the current value stored in "count" by 1.

So, if "count" is NOT greater than 1100 the program increases the current value stored in count by 1 and continues to the next section of functions which just happens to be the "ledsON" functions. The last thing in the "ledsON" section is "goto CheckCount;". This causes the program to return back CheckCount and start again. This continues until the value of "count" is greater than 1100 at which point the program goes directly to the section of the script labeled "ledsOFF" (skipping over the ledsON section completely). And the last thing that happens under the ledsOFF section is to reset the value of "count" back to zero, starting the entire process all over again.

Step 3: Key Items: #3 Four Different OFF Patterns

3. running four different OFF patterns at different times

OK, so I had this working with just one OFF section but it still wasn't just right. I decided to play around in the OFF part of the script and wound up with four different sections of OFF statements. Each time the program hits the threshold for running through the ON statements it goes to the ledsOFF section. And each time it goes to the ledsOFF section it runs a different OFF pattern based on a counter that keeps track of how many times the ledsOFF section has been run.

Once all four OFF patterns have been run the counter resets and the process starts over.

Step 4: Key Items: #4 Averaging the Sensor Value

4. using an average of the sensor value

When I began this project I was simply reading the current value of the sensor before every statement that had anything to do with that value. That worked but then I thought about using an average of the sensor value instead. This worked out great and is yet another way the program doesn't miss a lot of changes in that value. Prior to averaging the value it was possible to miss things because the value was either zero or to high.

Hint: Keeping the value ranges that turn on particular LEDs fairly linear helps smooth out the responses from those LEDs

Step 5: Key Item: # 5 Using Ranges

5. using ranges based on the average sensor value to turn on specific LEDs

The ON section has one "if" statement for each "light tube" on the board. Each of these has a different value range that has to be true for the LED to be turned on. Prior to averaging the sensor value the spread in a range for a particular LED could be pretty large, IE: turn LED1 on if the value is >100 and < 200. After averaging that spread is significantly lower, in some cases less than 5 points.

The main reason I was interested in averaging the sensor value was because that value may have been either too high or too low when it was read right before executing a command based on that value. Reading the value a few times and getting the average helped a lot.

Step 6: Key Item: #6 FC-S04's "sensitivity" Potentiometer (POT)

6. the FC-S04's "sensitivity" potentiometer (POT) plays a huge role in this

You are going to want to make friends with the POT on the FC-04 because it plays a huge role in the functionality of this sketch. All of the specifications you will see for the FC-04 will tell you that POT is to adjust sensitivity. That is true, but you need to understand what you are adjusting the sensitivity of!
To try and make a long story short, that POT adjusts the "trigger point" of the sensor. Meaning how much sound is required before the sensor starts to bring the OUT pin LOW. And it's the way the sensor uses that trigger point that makes this whole thing work. Get that POT set right and this sensor WILL NOT "switch" the state of the OUT pin directly between HIGH and LOW when it detects sound. If that were true we'd only have two values we could use, yet here we are using a large range of values to control the LEDs. The best I can tell you is my understanding of what this sensor is up to when it detects sound. To begin with the sensor holds the OUT pin HIGH when there is no sound being detected. With the POT set just right, when sound is detected the sensor DOES NOT switch the OUT pin directly to LOW. Instead it wants to bring the OUT pin LOW but because of where the trigger point is it hesitates and only hits LOW when the sound being detected is loud enough and long enough to get it there. So finding the sweet spot on that POT is going to be your biggest challenge. Play around with the POT and you'll discover that there's a very, very, fine line between the OUT pin being held HIGH or LOW. The way I adjust it is to turn it until all the LEDs are on and then turn it back a tiny, tiny bit at a time until the last LED is staying off. The further you turn the POT after the last LED is off, the louder the sound has to be to trigger the sensor.

NOTE: The difference between the sensor holding the OUT pin HIGH or LOW is miniscule. And I mean an itsybitsyteenyweeny (really small) change in that POTs position has a dramatic effect on this sketch (as does the volume of the input). This is one you just have to play with to get a good feel for. I won't admit to the number of times that I played with that POT when I shouldn't have! I managed to mess things up real good a couple of times and had to re-write most of my sketch to get things back in-line again.

Step 7: Key Item: #7 Ceramic Capacitor

7. a tiny little ceramic capacitor

I feel a little sneaky about this part but then again glad I thought of it. You can go directly from the sensors OUT pin to the analog input on your Arduino and this will work. But if you want more consistent results sneak in a little capacitor between those two points. Now when the sensor detects sound and starts to drop the OUT pin LOW we have a little power reserve sitting there that slows down that drop.

I used a ceramic capacitor because they are fast and easy to find in small values. Currently I'm using a 170nF capacitor. And believe me when I tell you I've experimented enough with different caps to know that's where I want to be.

Step 8: Required Items:

I'm not going to pretend it will be easy to duplicate my results but if you're still willing to give it a shot here is what you are going to need;

I will try to make this as easy as possible but no promises! The following list notes some items you can leave out to cut down the complications a little.

Items Needed;

  1. Arduino
  2. one (1) FC-S04 Sound Sensor module
  3. breadboard and patch cables
  4. sound source (something that plays music and for all I know nowadays that could be the stud in your tongue)
  5. Ten (10) LEDs (twenty LEDs if you want to create the "light board")
  6. Ten (10) 310 Ohm resistors (orange, orange, brown)
  7. One (1) Ceramic Capacitor with a value close to 1.5uf (1.5uf ceramic cap would have #'s 155 on it)
  8. For Lightboard - Ten (10) 11" plastic tubes (I used - believe it or not - hospital oxygen tubing)
  9. For Lightboard - 40" x 12" backer board Note: my first board was smaller, I went to 40" wide to get more space between the tubes - looks better but if I did it again I'd go even wider.
  10. For Lightboard - hot glue (someway to fasten the tubing to the backer board)
  11. lots of small gauge wire (I'd estimate there's about 40' (40 feet) of it in my project)
  12. Sound Meter (optional of course, I used mine to maintain the volume level of different songs)
  13. a ton of patience and some more in reserve

Step 9: Puttng Together the "Light Board"

This is not as complicated as it may seem but for those of you that would rather just play with ten LEDs on a breadboard go ahead and jump to the next step (Wiring).

For those of you still with me on this step here's how I put the board together.

Light Board Construction:

1. Cut board to 40"L x 12"W

2. Mark board for LED tubes (Note: Mark top and bottom of board so you can draw a straight line)

2a. 1st line is two (2) inches in from the end of the board (your first tube will be here)

2b. The rest of the lines are four (4) inches apart beginning from the first line above

3. add plastic tubing to the board using the lines above for placement (center the tube on board so there's about a 1/2 inch of board above and below the tube - for components)

Note: plastic tubing likes to curve - to keep mine straight for placement on the board I located some rod material (metal coat hanger) that I ran through the tubing. That kept it straight so I could work with it.

4. add LEDs - two LEDs per tube, one at each end (or just use 10, one at the bottom end of each tube - you can add the others later if you want to)

5. add resistors - one per tube, both LEDs in each tube use the same resistor

6. number your tubes (see pic 1 above) it makes figuring out which ones which a whole lot easier when they're flashing away.

Step 10: Wiring

So now that we have the light board or breadboard(s) ready to go, let's do some wiring.

One Important Note: DO NOT let the wire from the sensors OUT pin cross over or touch any other wires. The signal on the OUT wire can be degraded if that happens.

The wiring is the same for either option (breadboard or lightboard) with the only exception being the second LED in each tube on the light board. For those making the full light board, following the wiring instructions below and then simply connect the positive and negative from the 1st LED to the 2nd in each tube.

1. Add negative leads to each LED (bottom row only for light board)

Note: make the negative and positive leads long enough so that they can all reach your Arduino or breadboard. Hint, mark a center point one foot (1') in front of the light board and bring all of your leads to that point.

2. wrap all the negative leads together and add a pigtail (one more piece of wire (one foot) coming from that group). That one wire (pigtail) is all we need to ground all of the LEDs and we'll get back to that pigtail in a minute or two.

3. Add positive leads to one leg of each resistor

4. connect other leg of each resistor to it's LED

5. remember that pig tail off of the all the ground wires above, well put that in GND on your Arduino

6. The positive leads from the LEDs are connected to your Arduino's digital pins (3 through 12) starting with the first LED on the RIGHT hand side in PIN 3, next LED PIN4, and so on.

7. Add the Sound Sensor by connecting the 5v out from your Arduino to VCC on the sensor

Note: You may notice a small cap in the wiring diagram in line with the power to the sensor, that's to help smooth the power supply. It is not required, but doesn't hurt.

8. connect GND from your Arduino to GND on the sensor

9. connect the OUT pin from the sensor to one leg of the ceramic capacitor and connect the other leg of that capacitor to your Arduino's analog pin # 1 (A1) Note: the capacitor, even though very small, really helps smooth things out.

Step 11: Code to Syncronize the LEDs

Note: Be sure to check Step 13: "Last Minute Changes" where I've noted a least one change so far that was made after this Instructable was 99% completed.

Here you go! The current code file is attached and will load automatically into the Arduino interface for you, just double click the file.

The comments below, at beginning of code file, will hopefully answer the question(s) about how this all comes together. Though I will add here, one more time, a note about the POT on the sound sensor. Become friends with that POT, take it to dinner (and/or drinks), sleep with it, do whatever you have to in order to understand just how finicky she is (you married guys will understand). LADIES - JUST KIDDING! :-)

Some boring specifications are in the next step so I'll say goodbye here. Best of luck should you try this one. I know you'll swear I'm crazy and this doesn't work, that is until you get that sound sensor POT under control. I'm always willing to answer questions or help in any way I can so don't be shy if you have a question (limit 2 per customer) :-)

// written by Bradley S. Worthington-White 01/13/2016
 * The functionality of this sketch is as follows;
 * The "average" sensor value is the average of three contiguous readings 
 * of the sensors current value. That value is then used within a range 
 * of values to turn on specific LEDs.
 * The "ON" statements that turn the LEDs on are read multiple times
 * before any "OFF" statements are read.  How many times the "ON" 
 * statements are read is determined by the value of "count" 
 * under the "CheckCount" section.  
 * "UseSeq" determines which "ON" statements are read.  There are 
 * two choices for turning on the LEDs. Sequence one turns on 
 * each LED individually, while sequence two groups the LEDs 
 * together (two per group) and turns the groups on.
 * Once the value in count is met the "OFF" statements are read.
 * There are four individual "OFF" sequences, which one is read 
 * is determined by the value of OFFcount.  Because each "OFF" sequence
 * resets "count" to zero and returns to "CheckCount" only one "OFF"
 * sequence is read before the program returns to the "ON" statements
 * and the process starts all over again.
 /* NOTE:  DO NOT make any adjustments to the values in this script if you 
  *  have turned on the serial monitor (Serial.begin). Running the serial 
  *  monitor greatly reduces the speed of the program and will throw  
  *  everything off.  Use the serial monitor if you need to, but remember 
  *  to turn it off before changing any values in the script.  

const int SenOut = A1;  // output from sensor to Analog Pin A1
const int RLED1 = 3;   // assigning LEDs to digital pins 3 - 12
const int RLED2 = 4;
const int RLED3 = 5;
const int RLED4 = 6;
const int RLED5 = 7;
const int RLED6 = 8;
const int RLED7 = 9;
const int RLED8 = 10;
const int RLED9 = 11;
const int RLED10 = 12;

int count = 0;         //  counter for # of times the "ON" functions are read
int UseSeq = 0;        //  which "ON" function sequence to use
int OFFcount = 0;      //  counter for "OFF" functions

int sensVal [3];       //  creates array for sensor data
int i, j;              //  counter variables    
long average;          //  stores average sensor value

void setup()
  pinMode(RLED1, OUTPUT);  // setting digital pins as OUTPUT
  pinMode(RLED2, OUTPUT);
  pinMode(RLED3, OUTPUT);
  pinMode(RLED4, OUTPUT);
  pinMode(RLED5, OUTPUT);
  pinMode(RLED6, OUTPUT);
  pinMode(RLED7, OUTPUT);
  pinMode(RLED8, OUTPUT);
  pinMode(RLED9, OUTPUT);
  pinMode(RLED10, OUTPUT);

void loop()
  if (count > 1100) goto ledsOFF;// times "ON" statements read prior to "OFF" statements
  count = (count + 1);// increments "count" by 1 each run through the "ON" statements

  sensVal[(i++) % 3] = analogRead(SenOut);  // Begin averaging sensor value  
  average = 0;
  for (j = 0; j < 3; j++)
    average += sensVal[j];
  average = average / 3;                  // End averaging sensor value

  UseSeq = 1;                             // determines which "ON" sequence to use
  if (UseSeq == 1) goto ON1;
  if (UseSeq == 2) goto ON2;

ON1:                                      // first "ON" sequence
  if (average > 875 && average < 885) digitalWrite (RLED1, HIGH);
  if (average > 800 && average < 815) digitalWrite (RLED2, HIGH);
  if (average > 700 && average < 703) digitalWrite (RLED3, HIGH);
  if (average > 600 && average < 604) digitalWrite (RLED4, HIGH);
  if (average > 500 && average < 503) digitalWrite (RLED5, HIGH);
  if (average > 400 && average < 404) digitalWrite (RLED6, HIGH);
  if (average > 300 && average < 303) digitalWrite (RLED7, HIGH);
  if (average > 200 && average < 203) digitalWrite (RLED8, HIGH);
  if (average > 100 && average < 103) digitalWrite (RLED9, HIGH);
  if (average >  50 && average < 52)  digitalWrite (RLED10, HIGH);
  goto CheckCount;                          // returns to CheckCount

ON2:                                        // second "ON" sequence 
  if (average > 875 && average < 878) digitalWrite (RLED1, HIGH);
  if (average > 875 && average < 878) digitalWrite (RLED2, HIGH);
  if (average > 700 && average < 703) digitalWrite (RLED3, HIGH);
  if (average > 700 && average < 703) digitalWrite (RLED4, HIGH);
  if (average > 500 && average < 503) digitalWrite (RLED5, HIGH);
  if (average > 500 && average < 503) digitalWrite (RLED6, HIGH);
  if (average > 300 && average < 303) digitalWrite (RLED7, HIGH);
  if (average > 300 && average < 303) digitalWrite (RLED8, HIGH);
  if (average > 100 && average < 103) digitalWrite (RLED9, HIGH);
  if (average > 100 && average < 103) digitalWrite (RLED10, HIGH);
  goto CheckCount;

ledsOFF:                       // OFF sequences for LEDs
  OFFcount = (OFFcount + 1);   // counts number of times "OFF" statements have been read   if(OFFcount == 1) goto OFF1; // which "OFF" sequence is run
  else if (OFFcount == 2) goto OFF3;
  else if (OFFcount == 3) goto OFF2;
  else if (OFFcount == 4) goto OFF4;

OFF1:                                   // first "OFF" sequence
  digitalWrite (RLED1, LOW);
  digitalWrite (RLED2, LOW);
  digitalWrite (RLED3, LOW);
  digitalWrite (RLED4, LOW);
  digitalWrite (RLED5, LOW);
  count = 0;                 // resets the value of count under "CheckCount" to zero
  goto CheckCount;           // returns to CheckCount

OFF2:                        // second "OFF" sequence
  digitalWrite (RLED6, LOW);
  digitalWrite (RLED7, LOW);
  digitalWrite (RLED8, LOW);
  digitalWrite (RLED9, LOW);
  digitalWrite (RLED10, LOW);
  count = 0;
  goto CheckCount;

OFF3:                        // third "OFF" sequence
  digitalWrite (RLED1, LOW);
  digitalWrite (RLED2, LOW);
  digitalWrite (RLED3, LOW);
  digitalWrite (RLED4, LOW);
  digitalWrite (RLED5, LOW);
  digitalWrite (RLED6, LOW);
  digitalWrite (RLED7, LOW);
  digitalWrite (RLED8, LOW);
  digitalWrite (RLED9, LOW);
  digitalWrite (RLED10, LOW);
  count = 0;
  goto CheckCount;

OFF4:                        // fourth "OFF" sequence 
  digitalWrite (RLED10, LOW);
  digitalWrite (RLED9, LOW);
  digitalWrite (RLED8, LOW);
  digitalWrite (RLED7, LOW);
  digitalWrite (RLED6, LOW);
  digitalWrite (RLED5, LOW);
  digitalWrite (RLED4, LOW);
  digitalWrite (RLED3, LOW);
  digitalWrite (RLED2, LOW);
  digitalWrite (RLED1, LOW);
  OFFcount = 0;              // resets OFFcount to zero
  count = 0;
  goto CheckCount;

Step 12: FC-04 Sound Sensor Specifications

Detection Ability - detects sound waves but does not recognize particular sounds nor the frequency of a sound.

Working Voltage - 3.3 - 6 V

Output - single channel Digital - (output remains HIGH (5v) until it's pulled LOW when sound is detected)

Adjustable Sensitivity - via on-board POT (potentiometer) - This adjusts the OUTPUT voltage trigger point (how much sound is required before the sensor triggers the OUTPUT pin to go LOW. Adjusting this POT to high will cause the OUTPUT to remain HIGH, to low and OUTPUT will remain LOW. Finding the "sweet spot" where the module responds as desired can be tricky.

Pins on Module - three (3), VCC / GND / OUT

On-Board LEDs - Red power on, Green LED indicates sound is being detected (become friends with it also, watch it as you're adjusting the POT.

Dimensions: 1.73 x 0.63 x 0.35 (inches)

Step 13: Last Minute Changes

While working on this Instructable I added another section of code which pays attention to the average value being read from the sound sensor and whether that value is to high or too low. Meaning the average value is out of the range of values being used in the functions to turn on the LEDs.

The following code was inserted between the end of the averaging section and UseSeq. This code counts the number of times the sensor value is out of range and when that count reaches eight the program goes directly back to the CheckCount section. This has proved to significantly improve the overall synchronization effect. Which unfortunately is not demonstrated in the videos with this Instructable.

// after

average = average / 3;

// insert

if (average < 50)  avg LOW = (avgLOW +1)
if (average > 910) avg HIGH = (avgHIGH +1)

if (avgLOW >8)
  avgLOW = 0;
  goto CheckCount;
if (avgHIGH >8)
  avgHIGH = 0;
  goto CheckCount;

Step 14: Troubleshooting

Sorry you are having trouble, let's see if any of these ideas help;


1. General Troubleshooting

2. LEDs respond, but they just flicker

General Troubleshooting;

1. comment out the section that checks if the average value is to HIGH or to LOW. Add "/*" at the beginning of those statements and "*/" (without the quotes as below) at the end of them.


if (average < 50)  avgLOW = (avgLOW +1);
if (average > 910) avgHIGH = (avgHIGH +1);
if (avgLOW >8)
  avgLOW = 0;
  goto CheckCount;
if (avgHIGH >8)
  avgHIGH = 0;
  goto CheckCount;


Re-load the sketch with that section commented out to see if it makes any difference. If it doesn't, you can go ahead and leave it commented out for now.

1a. We need to know what the "value" is that is being returned when the average sensor value is determined.

So, begin by turning on the serial monitor and watching that value. And to do that:

1a1. add Serial.begin(9600); in the void setup() section of the script

1a2. in the void loop() section, under average = average / 3; add Serial.println (average);


1a3. open the serial monitor (three ways you can do that - in the Arduino interface click the magnifying glass icon in the upper right corner, or select TOOLS on the menu bar and then Serial Monitor, or Ctrl+Shift+M).

1a4. upload the sketch to your Arduino and you should see numbers scrolling on the serial monitor

HINT: The serial monitor isn't much help if the numbers are scrolling by so fast you really can't tell what is happening. That's when the "Auto Scroll" check box (lower left corner on serial monitor) becomes your friend. Uncheck that box to stop the screen from scrolling as new data is coming in and you can then scroll manually through the numbers for a better look. Turn "Auto Scroll" back on when you want to get back to the latest data coming in.

What kind of numbers are you seeing?

Does the value change when sound is detected?

Yes - what values are you seeing? When sound is detected, is there just a HIGH number and a LOW number or are there some values in-between that HIGH and LOW number? You'll need turn off Auto Scroll and scroll back up through the numbers to verify this.

No - the value doesn't change. Try playing with the POT on the sound sensor, turning it slowly while watching the value on the serial monitor. Can you get the value to change now?

For both Yes and No above - play with the POT on the sound sensor. Can you locate a "sweet spot" - where the value changes as soon as sound is detected

Bottom line is that the entire project is dependent upon that value; or more accurately it's dependent upon that value changing in a predictable manner.

So if the value only switches between HIGH or LOW and you never see anything other than that, I'd trying playing with the value of the capacitor that is in-line with the OUT signal.

If the value is changing - are the numbers you see close to the values in the ranges for the ledsON statements? If not those statements may require adjusting. If the values are close, turn the serial monitor off and trying playing with the POT on the sensor while there's music playing. Turn that POT SLOWLY and stop the second anything different happens with the LEDs. Now, apply a little pressure to the POT, in the direction you where turning it, to see what happens. You are not trying to "turn" the POT at this point, you just want to nudge it a little. This is where you get to become really good friends with that POT (it will try to be your enemy but you need to be the bigger person and demonstrate patience and understanding. The POT will eventually break down and want to be your friend).

2: LEDs respond, but they just flicker

Adjust the number of times the "ON" statements are being read. And in this case, where they are all on but flickering, lower the number. The number you want to change is in the "if" statement under the "CheckCount:" label;

if (count > 1100) goto ledsOFF; // 1100 is the number to play with

Raising this number causes the "ON" statements to be read more times before any LEDs are turned off. This results in more LEDs staying ON longer. To high a number though and the LEDs will be turned ON so often they appear to be always on.

Lowering this number causes the "ON" statements to be read less before the LEDs are turned off. This results in fewer LEDs being turned ON and they are turned OFF faster.

HINT: To adjust the number start with large changes to it and narrow it down as you go. For instance, if you change it from 1100 to 500 and you don't like it, try 900. If that's a little better you've narrowed it down to somewhere between 500 and 900, keep going until you find the number that looks best to you.
<p>added new video showing the addition of 10 lasers to the light board</p>
<p>Updated attached code file</p>
<p style="color: black;">Hi,</p><p style="color: black;">Not sure exactly what's doable on the Arduino, but if it's able to handle the &quot;RLEDn&quot; as an array instead (like &quot;RLED(n)&quot; or RLED[n]), you could tighten up your code a lot and drop all your large &quot;IF&quot; blocks (and hence speed it up as well) by</p><p style="color: black;">digitalWrite(RLED(INT(average/100), HIGH) ;assuming 10 bit</p><p style="color: black;">rather than repeatedly checking each possibility.</p><p style="color: black;">Regards</p>
Thank you! I'd thought about using an array but I was to lazy to sit there and figure out how! I admit it, I took the easy way out . I will be learning about them now, thank you. That is as soon as I can get back to that project. Put too much stuff on hold while I was playing with that one, now I have to clear the backlog. <br><br>And again, thank you.
<p>Backlogs... The crux of every tinkerer I guess, but also a nice place to put projects that need subconscious solving :)</p><p>Have a nice one.</p>
<p>Agreed, I have a desk thats full two tables full and projects on my bathroom sink counter. I guess thats a tell that I'm not married.</p>
<p>And still you haven't posted a single project here - shame on you ;)</p><p>Although tinkering usually has got a low &quot;WAF&quot;, just try to contain it to one or two rooms if possible and keep a few square meters for romance and you're set for a happy relationship... I think ;P </p>
<p>Added Step 14: Troubleshooting </p>

About This Instructable




Bio: Hi, I'm Brad. My interests spread over a large area and I tend to get carried away when something new peaks my interest. I ... More »
More by gr8yt:D2-3 Tracking & Obstacle Avoidance Smart Car DIY Kit LED Cycle Light Review Simple Serial Converter Makes Pro-Mini Programming Easy 
Add instructable to: