Quantcast
Channel: AUTOMALABS
Viewing all articles
Browse latest Browse all 63

ESP8266: Os LEDs do módulo ESP-01

$
0
0

ESP-01_leds

O LED vermelho é ligado diretamente à alimentação e o LED azul é ligado ao TX da serial. Se você não usar a serial no seu projeto pode controlar esse LED usando GPIO1, conforme o código abaixo:

/* Blink the blue LED on the ESP-01 module
 Based on Blink without Delay. This example code is in the public domain
 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */

const int ledPin =  1;  // The blue LED on the ESP-01 module is connected to GPIO1 
                        // (which is also the TXD pin; so we cannot user Serial at the same time

int ledState = LOW;     

unsigned long previousMillis = 0;
const long interval = 1000;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;   
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
    digitalWrite(ledPin, ledState);
  }
}

 


Viewing all articles
Browse latest Browse all 63