# Help! Arduino INPUT_PULLUP not inverting

I have a situation where I tried setting pins on my Atmel Mega328P to INPUT_PULLUP. I was told to expect an inverted input: a +5V would result in LOW reading and a GND would result in HIGH reading. However, what I found is the exact opposite. I tried checking my +5V and GND with some LEDs and they are definitely +5V and GND.

Below is my arduino code; I know it's not very efficient, but that's besides my point. My IDE is Eclipse C++.

#include "Arduino.h"
int count = 0;
void setup() {
Serial.begin(115200);
pinMode(PIN2, INPUT);
pinMode(PIN4, INPUT);
pinMode(PIN5, INPUT_PULLUP);
pinMode(PIN6, INPUT_PULLUP);
}

void loop() {
byte i = 0;
if(digitalRead(PIN2) == HIGH) i += 1;
if(digitalRead(PIN4) == HIGH) i += 2;
if(digitalRead(PIN5) == HIGH) i += 4;
if(digitalRead(PIN6) == HIGH) i += 8;
Serial.println(i, BIN);
delay(1000);
}

• Why are you expecting an inverted input? If I remember right, the input_pullup mode just connects an internal pullup resistor, no? – Hearth May 5 '17 at 1:10
• Perhaps you are mis-remembering a comment about what would happen with a pullup and a swtich to ground - switch "off" is a "1" while switch "on" is a "0" – Chris Stratton May 5 '17 at 1:27
• Sorry, I actually mis-remembered. Thanks for pointing out though. – krismath May 5 '17 at 1:56
• Should I remove this question then? – krismath May 5 '17 at 2:18
• Accepting an answer is generally a better way to mark it resolved; the available one isn't outstanding but it isn't wrong either. – Chris Stratton May 5 '17 at 2:53

if(digitalRead(PIN5) == LOW) i += 4;