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.