Pages: [1]   Go Down
Author Topic: Inverted HIGH and LOW values  (Read 891 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: