- I developed a simple push button project
- I used a wemos D1 mini
- I connected D3 pin to a pull down 1K resistor.
- I used a multimeter to measure D3 pin voltage.
When I push the button, D3 pin voltage changes from 0.x volt to 4.x volt. But digital read on D3 always return HIGH.
Please help me find the problem.
This in my sketch :
int ledPin = D2; // choose the pin for the LED
int inPin = D3; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
}
INPUT_PULLUP
mode if you want to activate by connecting the GPIO to GND; otherwise your input state will be inverted.