ATmega8L power issue I am doing a prototype using ATmega8L-8PU to detect temperature and control a relay and buzzer, but the schematic seems not work, therefore I do a simple test to verify the AVR's pins are working perfectly or not.

I using the example sketch - Blink to control Digital-13 to let LED blink. It is work.

Then I do a second sketch to test all pins (Due to leak of LED, I test first 8 pins.) It failed. Second Sketch is quite simple and strict forward: blink D0-D7 LED one by one.

char i, j, pcnt = 1;

char startDigitalPin = 0;
char maxDigitalPin = 7;

void setup()
{
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);

    // put your setup code here, to run once:
    for(i=startDigitalPin; i&lt;=maxDigitalPin; i++) {
        pinMode(i, OUTPUT);
        digitalWrite(i, LOW);
    }
}

void loop()
{
    // put your main code here, to run repeatedly:
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);

    for(i=startDigitalPin; i&lt;=maxDigitalPin; i++) {
        for(j=i; j&lt;=maxDigitalPin; j++) {
            digitalWrite(j, HIGH);
            delay(100 * pcnt);
            digitalWrite(j, LOW);
            delay(100 * pcnt);
        }

        digitalWrite(i, HIGH);
        delay(200 * pcnt);
    }

    pcnt++;

    if(pcnt &gt; 10) {
        pcnt = 1;
        delay(8000);
    }
}


Question:


Why I using Blink example sketch, D13 is work fine, the LED light on with normal bright.
Why second sketch, the D13 LED super dark, but it light on.


Check it out these 2 videos in youtube.
https://www.youtube.com/watch?v=sknNPxqg5zc
https://www.youtube.com/watch?v=KWsdP3egsvY

I have burn a bootloader to ATmega8L-8PU (Summary Datasheet) using Arduino IDE 1.6.5 with MiniCore, Config: ATmega8 External 8MHz.

Parts in my bearboard using:


ATmega8L-8PU
2 x 22pf
1 x 100nf
1 x 8MHx crystal
9 x LED with 330Ohm resistor
I tested your sketch after adding pinMode(13, OUTPUT) in the setup, and it works as you intended.

But, as you don't post your schematic, I was only able to chech on-board LED blinking.

void setup()
{
  pinMode(13, OUTPUT);

  for (int i=0; i &lt; 3; i++) {
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);
  }

    // put your setup code here, to run once:
    for(i=startDigitalPin; i&lt;=maxDigitalPin; i++) {
        pinMode(i, OUTPUT);
       digitalWrite(i, LOW);
    }
}


I also reduce your code using a for loop.