Pages: [1] 2   Go Down
Author Topic: HIGH is off and LOW is on  (Read 861 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

Hi,

I have had my Arduino Ethernet now for 6 months. LOADS of fun with it. But I have noticed when I write a pin HIGH it turns it off and if I write it LOW it turns it on. It as been the way since I got it. Is there something wrong with it?

I also noticed that the analog pins read 0 when I put power to them. Is that right?

Thanks,
Donnie
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25820
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the "it" that is turned on or off?
If "it" is a LED connected to a pin, it depends how it is wired as to how it behaves.
Where is your code?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Texas
Offline Offline
Edison Member
*
Karma: 25
Posts: 1298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you write LOW, the pin should go to ground ( is that on or off to you), and vice versa.
Have you used a volt meter to see what you are getting?
Logged

Good luck, Jack

Texas
Offline Offline
Edison Member
*
Karma: 25
Posts: 1298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I also noticed that the analog pins read 0 when I put power to them. Is that right?
Well, if you put to much power, they may burn up.

They read voltage, normally between 0 and 5 volts.
What "power did you put on what pin? What code did you use to read, and display that?

Logged

Good luck, Jack

Offline Offline
Edison Member
*
Karma: 32
Posts: 1288
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But I have noticed when I write a pin HIGH it turns it off and if I write it LOW it turns it on. It as been the way since I got it. Is there something wrong with it?
Current flows when there is a difference in voltage.   If you connect one end of an LED/resistor to +5V and the other end to an Arduino output, the LED will come on when the ouput goes low (assuming it's wired with the correct polarity smiley-wink ).

If both ends of the LED/resistor are connected to 5V, there is no difference, no current will flow, and the LED won't light-up.   It's sort-of like water-flow...  If there is no pressure difference, or a difference in height, the water won't flow... And the direction of the water-flow is always from high-to-low.

Similarly, I'm using the internal pull-up resistor on an input with a switch wired to ground.  When I turn the switch on, it pulls the input low.

Quote
I also noticed that the analog pins read 0 when I put power to them. Is that right?
Something's wrong...  If you connect +5V to an analog pin, it should read (about) 1023.  The "power" needs to share a common ground with the Arduino.   (Again we are looking for a difference, and you need the ground reference.)  And, you can damage the Arduino by applying a negative voltage or a voltage higher than +5V.

Logged

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

For example, in the sketch below I have to turn led to LOW to get it to turn on. If I set it to HIGH then the led will not turn on.

For the analog, if I turn on pin 8 and jump it start to A0. Thats when I get a reading on the serial monitor of 0.

Thanks,
Donnie

}
Code:
int led = 5;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, LOW);   // turn the LED on (HIGH is the voltage level)
}
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2362
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only way this is possible is if you've got it wired up wrongly.

for example. digitalWrite(3,HIGH);  Pin 3 spits out 4.7v or whatever it is.


All I can think of is, that you have +5v connected to the negative side. so when you
do LOW, it completes the circuit, up until that point the potential difference is equal?

Logged

Sitting in the garage.
Offline Offline
Sr. Member
****
Karma: 4
Posts: 461
I made the pretty light blink.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One could write low to a PNP transistor and get light, but cj's assumption of mis-wiring seems right.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sink or source for the LED? If the LED is connected to the 5 pin and +5v, then the led might light when the 5 pin goes low.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Southeast US
Offline Offline
God Member
*****
Karma: 15
Posts: 683
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Take a moment to think about the following 2 circuits, and you may realize the answer to your question (especially if you examine circuit 1):

Code:
Circuit 1:
Vcc ----/\/\/\---|>|---Arduino Pin

Circuit 2:
Arduino Pin---/\/\/\---|>|---GND

--|>|--  Diode
-/\/\/\-  Resistor

PS (I'm far too lazy to draw these in something other than text)
Logged

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

Ok, I unplugged everything from my arduino and put a volt meter to it. The pins are giving me over 4 volts when I turn them to HIGH. So that left my relay module. So I did some testing on it, and turns out, to trigger a relay on it, it needs a ground signal sent to them. I remember not being able to find any information on the wiring on it when I got.

Was that bad for the arduino for it to be hooked up that way? How do I go about sending ground signal to each relay with the arduino board

Here is the relay I am using.

http://ep.yimg.com/ay/yhst-62196343123315/mcu-4-channel-relay-expansion-board-support-avr-51-pic-4-arduino-compatible-4.gif

Thanks for all your help.
Logged

Southeast US
Offline Offline
God Member
*****
Karma: 15
Posts: 683
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What happens when you set the arduino pin LOW?
Logged

Sitting in the garage.
Offline Offline
Sr. Member
****
Karma: 4
Posts: 461
I made the pretty light blink.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are using a relay to turn on an LED?

Do mirith's simple circuit #2.  The LED will shine when you write the pin HIGH.
Logged

Texas
Offline Offline
Edison Member
*
Karma: 25
Posts: 1298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No need to use a relay to light a (normal) led. If you do want to use the relay board, and a LOW activates the relay  (that is sorta an inverter circuit). You can invert it again. One way is to use the other side of the relay output. If you are going to NO (normally open), just switch to NC (normally closed).

I assume you are just experimenting, not creating any mission critical system.
Logged

Good luck, Jack

Southeast US
Offline Offline
God Member
*****
Karma: 15
Posts: 683
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Option #3:
Code:
//At the beginning of your code before anything
#define ON LOW
#define OFF HIGH
...

digitalWrite(ledPin, ON);

PS, watch that you don't over current each pin if using the Arduino to drive the LED
PSS, I hear transistors can act like digital switches, and are cheaper than relays.
Logged

Pages: [1] 2   Go Up
Jump to: