Error when trying to write analog and digital signals from different pins (Arduino UNO) I'm using the Arduino UNO and started noticing some funny behavior when I was trying a few basic projects. Specifically when trying to write an analog signal through one of the PWM pins, then a digital signal through another.

Using some LED's connected to a few different permutations of pins 8-13, I found that when I have an analog output set for one of the pins (in this case 9, 10, or 11 as they're the only one's of the set capable of PWM) and then try to output a digital signal from a different pin to another LED the digital signal seems much weaker. That is, the LED shines very very dim.

The pins 2-7 work fine.
Does the behavior described above indicate anything wrong with the arduino? are those pins potentially damaged, or is there something I'm not understanding here?

My code:

void setup()
{}

void loop()
{
   analogWrite(9, 255);
   delay(1000);
   analogWrite(9, 0);
   delay(2000);
   digitalWrite(8, HIGH);
   delay(1000);
   digitalWrite(8, LOW);
   delay(2000);
}
I tested your code and it does indeed behave the way you said. But that is because you have not declared any pins as output.

analogWrite does this for you automatically in the library, however digitalWrite does not. This is because sending a digital pin HIGH when it is INPUT turns on the internal pull-up resistors. These are around 50k. Thus you will only see very dim output on the LED. Add this line to setup:

 pinMode (8, OUTPUT); 


(And preferably pin 9 as well, just in case you decide to change to digital writes later).