Go Down

Topic: HIGH is off and LOW is on (Read 1 time) previous topic - next topic

grandleo75

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

AWOL

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?
"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.

jack wp

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?
Good luck, Jack

jack wp

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?

Good luck, Jack

DVDdoug

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 ;) ).

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.


grandleo75

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: [Select]
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)
}

cjdelphi

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?


bigred1212

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

zoomkat

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.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

mirith

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: [Select]

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)

grandleo75

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.

mirith

What happens when you set the arduino pin LOW?

bigred1212

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.

jack wp

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.
Good luck, Jack

mirith

Option #3:
Code: [Select]

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

Go Up