LEDs are shining bad

Hi! I have a problem. On my Arduino MEGA 2560, LEDs are on HIGH power on DIGITAL pin shining very bad. In the past they all worked perfect. I do not know what to do. Please if u know anything write me under the topis or on vitodro@gmail.com

TNX

You of course always use a series resistor with each LED.
Show us an image of your wiring.

You got the pins set as output with pinmode?

In response to your pm, I mean have you used pinMode to set each pin as an output?

Read the NOTE on this reference page.

void setup()
{
pinMode(10, OUTPUT)  //edit.... I typed this above setup() earlier sorry
digitalWrite(10, HIGH)
}

void loop() {}

JimboZA:
In response to your pm, I mean have you used pinMode to set each pin as an output?

Read the NOTE on this reference page.

pinMode(10, OUTPUT)

void setup()
{
digitalWrite(10, HIGH)
}

void loop() {}




Yes, here is the program:

void setup() {

Serial.begin(9600);
}


void loop() {

int sensorValue = analogRead(A0);

float voltage = sensorValue * (5.0 / 1023.0);

Serial.println(voltage);




if (voltage<1) digitalWrite(52, HIGH);


if (voltage>1) digitalWrite(52, LOW);


if (voltage<1) digitalWrite(42, LOW);


if (voltage>1, voltage<4) digitalWrite(42, HIGH);


if (voltage>4) digitalWrite(42, LOW);


if (voltage>4) digitalWrite(30, HIGH);

if (voltage<4) digitalWrite(30, LOW);

if (voltage<1) digitalWrite(42, LOW);

}

There's no pinMode line in that code.

The note I linked to, specifically says an LED will be dull if you don't use pinMode to make the pin an output.

void setup() {
  
  Serial.begin(9600);
}


void loop() {
 
  int sensorValue = analogRead(A0);

  float voltage = sensorValue * (5.0 / 1023.0);

  Serial.println(voltage);
  
  

  
  if (voltage<1) digitalWrite(52, HIGH);


  if (voltage>1) digitalWrite(52, LOW);


  if (voltage<1) digitalWrite(42, LOW);


  if (voltage>1, voltage<4) digitalWrite(42, HIGH);
  
  
  if (voltage>4) digitalWrite(42, LOW);
  
  
  if (voltage>4) digitalWrite(30, HIGH);
  
  if (voltage<4) digitalWrite(30, LOW);
  
  if (voltage<1) digitalWrite(42, LOW);
  
}

What to do then?

But LEDs are shining, just so badly, that it is useless.

vitothelegend: What to do then?

Add pinMode commands into your code, one for each in that you use like 52 and 42, inside setup() like this:

void setup()
{
pinMode(42, OUTPUT);
pinMode(52, OUTPUT);
// and for any other pin with an led connected
//
}

this just appeard as an error:

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: “Arduino Mega 2560 or Mega ADK”
Velikost binarne skice: 6.584 bajtov (od 258.048 možnih bajtov)

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail

Thanks you very much. It is working now.