ESP8266 – blinky with delay function

This blinky project shows how to interface LED to the ESP8266 and write a simple program to make the LED blink. The full code is on Github, click here.

Parts List

  • ESP8266 Development Module (for example, based on ESP-12N, with build in LED)


This code is written in C and can be compiled using xtensa-lx106-elf-gcc.  Don’t know how to start? Please read about building ESP8266 toolchain for Linux.

 * Copyright (c) 2017, Łukasz Marcin Podkalicki <>
 * ESP8266/001
 * Blinky with delay function.

#include <esp/gpio.h>
#include "espressif/esp_common.h"
#include "esp/uart.h"
#include "FreeRTOS.h"
#include "task.h"

#define    LED_PIN        (2)

static void
blinky_task(void *prv)

    gpio_enable(LED_PIN, GPIO_OUTPUT);

    while (1) {
        gpio_write(LED_PIN, 1);
                vTaskDelay(100 / portTICK_PERIOD_MS);
        gpio_write(LED_PIN, 0);
        vTaskDelay(100 / portTICK_PERIOD_MS);


    uart_set_baud(0, 115200);
    xTaskCreate(blinky_task, "blinky_task", 256, NULL, 2, NULL);

Leave a Comment