I am using a new Arduino UNO clone ( Sainsmart ).
I have tried to light LEDs on pins 9,10 and 11. The LEDs are 3mm types with 1K ohm
limit resistors.
The LED on pin9 is OK, but those on pins 10 and 11 dont light up very well, or at all.
It transpires that there is something wrong with the HIGH state on 10 and 11.
With no load the voltage reads about 4.0 whereas that on the good pin is nearer 4.5.
Under load ( and we are only talking 3mA here) the pin voltage collapses to around 2V.
Is the chip dud?
Ooops!
Well, I did and I didnt.
What I wrote ( in setup) was this:
pinMode ( red, HIGH); (yellow, HIGH); (green, HIGH):
Only the red LED was OK.
I needed to separate the 3 LEDs and give each its own 'pinMode' command.
When I did that, all was well.
Thanks, I was shi**ing bricks because I thought I'd trashed the chip.
Why didnt the IDE throw up a syntax error?
There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors
Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and the programmer has forgotten to use pinMode() to set the pins to outputs.
Because that happens to be a legal C statement. It means, approximately "take the value of yellow, and throw it away, substituting in the overall expressing the value HIGH instead. Now, you didn't actually DO anything with that expression, so throw that value away too." (Isn't that great? The "comma" operator is one of the most reviled things in C, I think.)
If arduino had extra warnings turned on, you would have gotten concise messages:
bar.c:17: warning: left-hand operand of comma expression has no effect
bar.c:17: warning: statement with no effect