/* Based on the ESP8266 Blink by Simon Peter Blink the red LED(pin 13), and green LED(pin 12) alternating. Build in pushbutton on pin 14 on the ESP-01 module This example code is in the public domain */ int ledGreen = 13; int ledRed = 12; int buttonPin = 14; int buttonState = 0; void setup() { pinMode(ledGreen, OUTPUT); // Initialize the LED pin as an output pinMode(ledRed, OUTPUT); // Initialize the LED pin as an output pinMode(buttonPin, INPUT); //initialize button pin as input Serial.begin(9600); } void loop() { digitalWrite(ledGreen, HIGH); // Turn the LED on digitalWrite(ledRed, LOW); // Turn the LED off Serial.println("low"); delay(1000); // Wait for a second digitalWrite(ledGreen, LOW); digitalWrite(ledRed, HIGH); Serial.println("high"); delay(500); // Wait for half second buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { Serial.println("btn high"); } else { Serial.println("btn low"); } }