Go Down

Topic: Inverted HIGH and LOW values (Read 1 time) previous topic - next topic

accatyyc

So this is an (probably simple) interesting little issue I'm having. Just bought an Arduino UNO (R2) and I'm playing around with some LED's and matrixes. I have no problems running programs on it, the only problem is that HIGH and LOW seem to be inverted. So basically if I want to light a LED I have to write:

digitalWrite(outputPin, LOW);

and to turn it off again:

digitalWrite(outputPin, HIGH);

Anyone know what might be causing this (or if I am missing something fundamental here)? Not that it's a real problem for writing programs, it's just a bit harder to read them. Still weird though!

johnwasser

If you have the other end of the LED connected to +5V instead of Ground, current will flow when the pin is at 0V/Ground/LOW and not when the pin is at 5V/HIGH.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Grumpy_Mike

Quote
if I am missing something fundamental here

Yes there are two ways of powering an LED current sourcing and current sinking.
The concepts of HIGH and LOW are logic levels, they only equate to ON and OFF if you use positive logic wiring, that is current sourcing. Most real programmers don't use current sourcing but sinking where LOW will turn an output ON. This is perfectly normal, glad to see you are doing it the right way round.

accatyyc

Thanks for the answers! The problem was that I missed the GND-pin with one pin which was a little hard to spot since the text is almost in between. Stupid me.

Thanks for the tips grumpy_mike, while it wasn't what was causing my "problem" today it's good to have in mind for the future.


Grumpy_Mike

Quote
The problem was that I missed the GND-pin with one pin

That would suggest you had the LED the wrong way round or it would not have lit up.

accatyyc

That is correct. I was using a LED bar graph without direction indicators so it was a simple matter of turning it around on the breadboard when I noticed it wouldn't light up when the ground was correctly connected.

Go Up