Sound Reactive Leds problem

Greetings,

I am doing a project where I am controlling 160 parralel wired LED's with the use of Arduino Nano, a TIP121 transistor, and a FC-04 Sound sensor module. The LEDs should turn off when the threshold of the sensor is met, and then turn on again. So they react to the sound.

the problem I have is that it all works fine, until a random reset of the arduino, then it works again, and then it resets again, with decreasing time in between resets until it just keeps on resetting.

the project is powered by a 5V usb adapter which can supply 2.1 Ampere.

in the attachments there is a picture of the circuit, there is also a 330 ohm resistor between arduino pin and base of transistor.. Here is the code:

int soundSensorPin = 8; //Input pin for sound sensor
int ledPin = 9; // Output pin to Transistor
int statusLed = 7;
int signalLed = 6;
void setup() {
  
  pinMode(ledPin, OUTPUT);
  pinMode(statusLed, OUTPUT);
  pinMode(signalLed, OUTPUT);
  pinMode(soundSensorPin, INPUT);
  digitalWrite(statusLed, HIGH);
  
}

// the loop function runs over and over again forever
void loop() {
  boolean soundSensorSignal = digitalRead(soundSensorPin); //read sound sensor value
  
  if (soundSensorSignal == 1) {
    analogWrite(ledPin, 255);
    digitalWrite(signalLed, LOW);// turn leds on
    delay(20); //wait 15ms for transistor to catch up
  }
  else {

    analogWrite(ledPin, 0); //turn leds off
    digitalWrite(signalLed, HIGH);
     delay(20);
  }
}

I dont know what is causing this. I hope some of you can help me.

thanks in advance.

You need a current limiting resistor for each of the 160 LEDs and make sure the total doesn't exceed about 2 Amps.

Without current limiting resistors the LEDs will pull excess current from the power supply and "suck down" the voltage to the LED's breakdown voltage (about 2V).

The resistor to the base of the transistor limits the current out of the Arduino, but it doesn't limit the current from the power supply through the LEDs & transistor.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png

A fritzy is not a schematic.

When you draw your complete circuit, show us how you have connected 6 of the LEDs, we can assume the other 154 are connected the same.

What is your electronics, programming, arduino, hardware experience?

Thanks.. Tom.. :slight_smile:

As already mentioned, LEDs need means to limit their operating current, usually a resistor. A number of LEDs can be wired in series, with only one resistor limiting the current through these LEDs. But then a higher supply voltage should be used, because every LED requires about 2V to shine, and the voltages sum up in serial connection. E.g. 5 LED in series require 10V, so that a 12V supply can be used and the remaining 2V are left for the current limiting resistor. Of course the transistor must support that voltage (Vce, Vds), but almost every transistor can switch up to 15V DC. This limit will become more important when you use higher supply voltages, where up to 48V DC are commonly used to drive high power devices.