60Views3Replies

Author Options:

Help with sketch, and a safety question? Answered

The model I'm building calls for 13 LED's and fiber optics running from about 6 more LED's. I have managed to get them all running on one arduino and breadboard, will this be safe?

The arduino will run on a mains adapter and has a pot for flashing speed, a pot for brightness, and an on/off switch.

After lots of trial an error and a lot of luck I have the other LED's acting just as I want. But I am having trouble getting 11 and 12 to stop flashing, any ideas?

int sensorValue = 0; //make a variable where you can store incoming
//analog values

void setup(){
pinMode(12, OUTPUT); //tell arduino what you'll be using these pins
pinMode(11, OUTPUT); // for (output).
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);


Serial.begin(9600); //initialize serial
}

void loop(){ //we put the code we want executed in a loop

Serial.print("sensor = " ); //sends what's in quotes via serial
Serial.println(sensorValue); //sends our variable (sensorValue)
//via serial




digitalWrite(12,HIGH); // lights the led
digitalWrite(11,HIGH);
digitalWrite(8,HIGH);


digitalWrite(4, HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(4, LOW);
delay(15);

digitalWrite(6, HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(6, LOW);
delay(15);

digitalWrite(5, HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(5, LOW);
delay(15);

digitalWrite(7, HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(7, LOW);
delay(15);


digitalWrite(5, HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(5, LOW);
delay(15);

digitalWrite(10,HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(10,LOW);
delay(15);

digitalWrite(9,HIGH);
sensorValue = analogRead(0);
delay(sensorValue + 25);
digitalWrite(9,LOW);
delay(15);


}

Discussions

0
None
mpilchfamily

Best Answer 4 years ago

I see no current limiting resistors on any of those LEDs. So they are pulling every bit of current they possibly can. So as all the others are flashing on and off they are drawing power away from 11 and 12 causing them to flicker. Each one of those LEDs needs to have a resistor on them. The thing about LEDs are they will continue to pull current till the power supply cannot offer anymore or they burn up. The arduino will max out at offering 1A minus the 100mA or less the board itself will draw. If you had current limiting resistors in place to limit the LEDs to about 20mA you wouldn't have this issue. Google an LED calc and type in the LED specs along with the power supply of 5V to get the resistor value needed for each LED. Do not calculate the LEDs like they are wired in sereis or parallel. Since they each go to a seprate pin on the board they are stand alone LEDs.

0
None
steveastrouk

4 years ago

There's nothing in the code that should cause a problem, so you need to look at the electronics. If you have a voltmeter, it will be instructive to measure the voltage on the Processor chip.

0
None
lifeofB

4 years ago

My board...

3.JPG