Cant get pull down resistor to function

I have an arduino set up to read a ~3.2V power in line that I need to read the state of (high or low). Without a pull down resistor I get very inconsistent readings because the pin is left floating. When the pull down resistor is in place, however, the circuit reads the state as always being low. A diagram and arduino sketch are attached if you need more information. Please Help.

Pull Down Resistor.jpg

int psu3V = 2;
int psuLED = 13;
void setup() {
  pinMode(psu3V, INPUT);
  pinMode(psuLED, OUTPUT);
}

void loop() {
  if (digitalRead(psu3V) == HIGH) {
    digitalWrite(psuLED, HIGH);
  }
  if (digitalRead(psu3V) == LOW) {
    digitalWrite(psuLED, LOW);
  }
}

Pull Down Resistor.jpg

TestBench.ino (261 Bytes)

OP’s stuff.

int psu3V = 2;
int psuLED = 13;
void setup() {
  pinMode(psu3V, INPUT);
  pinMode(psuLED, OUTPUT);
}

void loop() {
  if (digitalRead(psu3V) == HIGH) {
    digitalWrite(psuLED, HIGH);
  }
  if (digitalRead(psu3V) == LOW) {
    digitalWrite(psuLED, LOW);
  }
}

Pull Down Resistor.jpg

The circuit looks wwwrrrooonnnggg

Is #2 connected to 3.2v all the time?

I would suggest turning on the internal pull up but we need to know exactly what you are doing.

What Arduino is this?

larryd:
The circuit looks wwwrrrooonnnggg

Is #2 connected to 3.2v all the time?

I would suggest turning on the internal pull up but we need to know exactly what you are doing.

What Arduino is this?

The arduino is there so I can monitor a computer power supply I converted to a bench power supply. The +3.2V line is only on when the power supply is on. When the power supply is off, the line has ~2mV on it.
I want the arduino to turn on an led that is connected to the output pin(4 in this case) when the input pin (2) is high.
(The arduino is an uno)

You will need to connect the Arduino GND to the power supply GND.

You could also use the +5v from you bench top supply, just make sure it never goes over 5v.

Thank you, that worked

If all you want is to light a LED when the power is on, the arduino there is a tad redundant… :slight_smile:
Just stick a led with an appropriated resistor and you are done.

If you’re just testing to see how it can be done that’s another story, but if planning to have it there allays, than just use a led.

ocsav:
If all you want is to light a LED when the power is on, the arduino there is a tad redundant... :slight_smile:
Just stick a led with an appropriated resistor and you are done.

If you're just testing to see how it can be done that's another story, but if planning to have it there allays, than just use a led.

Yeah, I'm using it to monitor the status of the power supply. It has been known to overheat so I'm going to log the power on time and temperature with a thermometer. Eventually ill also get a mosfet that goes between the PSU's GND and its power on wire so I can have it automatically shut down when it gets too hot.

If this is still of interest to you, another way to read that 3.2V signal, would be to use an Analog Pin and do an analogRead, like this:

// Untested
#define psu3V A0
const int PSU3V_THRESH = 1.6*1023/5;  // Set threshold to half way between 3.2V and 0V
int psuLED = LED_BUILTIN;  // Get used to using LED_BUILTIN, instead of '13', so your code is more portable
void setup() {
  pinMode(psuLED, OUTPUT);
}

void loop() {
  if (analogRead(psu3V) >= PSU3V_THRESH) {
    digitalWrite(psuLED, HIGH);
  }
  else {  // No need to do the read twice -- there are only two states
    digitalWrite(psuLED, LOW);
  }
}

ReverseEMF:
If this is still of interest to you, the reason your original circuit wasn’t working, is probably because an Arduino UNO runs at 5V. And the minimum input voltage is defined as 70% of VCC.

For the ATmega based Arduinos running at 5V, the logic high threshold is 60%, not 70%

VCC = 2.4V - 5.5V, >= 0.6 x VCC for a High
VCC = 2.4V - 5.5V, <= 0.3 x VCC for a Low

CrossRoads:
VCC = 2.4V - 5.5V, >= 0.6 x VCC for a High
VCC = 2.4V - 5.5V, <= 0.3 x VCC for a Low

Flerp! You’re right! I’ll fix my post. :stuck_out_tongue: