It prints 1 in serial if voltage is above 2.5V and 0 if voltage is under 2.5v.I tried with a pot and it the same(middle to pin, sides to gnd and 3.3v)
I expected, when going from high to low, to stay high until a lower voltage(1-1.5v)because I wanted to see what is that lower threshold and then switch to low.


I expected, when going from high to low, to stay high until a lower voltage(1-1.5v)because I wanted to see what is that lower threshold and then switch to low.
- Code:
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the Serial Monitor
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/DigitalReadSerial
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}

