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