Re: NodeMCU - running arduino - User Button
Posted: Thu Jun 25, 2015 11:53 am
Maybe the board itself has a pullup ? because otherwise, this switch will be useless ...
-->
Open Community Forum for ESP8266, Come share Arduino and IoT (Internet of Things)
https://www.esp8266.com/
if (digitalRead(16)==0) {
// do stuff...
pinMode(16,OUTPUT);
digitalWrite(16,HIGH);
delay(1);
pinMode(16,INPUT);
const int buttonPin = 16;
const int ledPin = 1;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin) == HIGH)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
pinMode(buttonPin, OUTPUT);
digitalWrite(buttonPin, HIGH);
pinMode(buttonPin, INPUT);
}
}