Tringing to get two gpio inputs read using a Arduino Micro.
However when running this little debugging sketch below, my output on the serial command for for the pins is arbitrarily switching even nothing is connected to the board. Also both pins outputs are in synch with each other.
while reading the documentation it said
"If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly)."
If that is the case how are we able to connect digitla pins as input gpio and wait for high and low triggers from outside sensors
This is the outputs i am getting on the serial monitor....
00
00
00
00
01
11
11
11
11
11
11
00
00
Really stumped...
const int ONN = 4;
const int OFF = 5;
void setup()
{
Serial.begin(9600);
pinMode(ONN, INPUT);
pinMode(OFF, INPUT);
}
void loop()
{
delay(250);
int Digi4 = digitalRead(ONN);
int Digi5 = digitalRead(OFF);
Serial.print(Digi4);
Serial.println(Digi5);
}
You turned the internal pullup resistors off. Why?
My attached sensor is giving GPIO outputs, which are digital no?
Typically, yes. But, I'm almost certain that you didn't open a Mouser catalog and order a "sensor". I'm almost positive that you ordered a very specific kind of sensor. So, quit playing games and tell us what kind of sensor it is and how it is actually wired.