user31104: I developed simple push button project
I used wemos D1 mini
I connected D3 pin to pull down 1K resistor.
I used 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. Thanks in advance
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);  
  }
}


user31030: First of all - read your post before you actually post it. This code is no readable. And if you have problems with electronics add picture of schematics how you connected your board. There can be problem too.

D3    IO, 10k Pull-up GPIO0

Source: https://www.wemos.cc/product/d1-mini-pro.html
Your D3 pin have internally pull-up so no doubt that it reads HIGH all the time. Connect your board like on picture below or change your reading pin to D0 for example (It has no other function than simple IO).

simulate this circuit – Schematic created using CircuitLab
For this case you can trust internal pull-up but in more complicated projects you should add your own one.
For more information about pull-ups and pull-downs check this article: http://www.electronics-tutorials.ws/logic/pull-up-resistor.html

user2881: The problem is that when the button isn't pressed, the voltage at pin D3 is just floating. Since there is nothing attached, the voltage at the pin can be anything. To prevent this, you use a pull-down resistor, so that when the button isn't pressed, the voltage at D3 is pulled to ground, and you will get a LOW using digitalRead.

simulate this circuit – Schematic created using CircuitLab

31104: <p>I developed simple push button project
I used wemos D1 mini
I connected D3 pin to pull down 1K resistor.</p>

<p>I used multimeter to measure D3 pin voltage.</p>

<p>When i push the button, D3 pin voltage changes from 0.x volt to 4.x volt</p>

<p>But digital read on D3 always return HIGH.</p>

<p>Please help me find the problem. Thanks in advance</p>

<p>This in my sketch :</p>

<pre><code>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);  
  }
}
</code></pre>
 31030: <p>First of all - read your post before you actually post it. This code is no readable. And if you have problems with electronics add picture of schematics how you connected your board. There can be problem too.</p>

<blockquote>
  <p>D3    IO, 10k Pull-up GPIO0</p>
</blockquote>

<p>Source: <a href="https://www.wemos.cc/product/d1-mini-pro.html" rel="nofollow noreferrer">https://www.wemos.cc/product/d1-mini-pro.html</a></p>

<p>Your D3 pin have internally pull-up so no doubt that it reads HIGH all the time. Connect your board like on picture below or change your reading pin to D0 for example (It has no other function than simple IO).</p>



<p><img src="https://i.stack.imgur.com/yxbFX.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fyxbFX.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>

<p>For this case you can trust internal pull-up but in more complicated projects you should add your own one.</p>

<p>For more information about pull-ups and pull-downs check this article: <a href="http://www.electronics-tutorials.ws/logic/pull-up-resistor.html" rel="nofollow noreferrer">http://www.electronics-tutorials.ws/logic/pull-up-resistor.html</a></p>
 2881: <p>The problem is that when the button isn't pressed, the voltage at pin D3 is just floating. Since there is nothing attached, the voltage at the pin can be anything. To prevent this, you use a pull-down resistor, so that when the button isn't pressed, the voltage at D3 is pulled to ground, and you will get a LOW using digitalRead.</p>



<p><img src="https://i.stack.imgur.com/0Ztn9.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f0Ztn9.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="noreferrer">CircuitLab</a></sup></p>
