// ---------------------------------------------------------------------------
// (| " Blynk_Pi_Pico_W.c                                                  "|)
// (| " Este es un sencillo sketch que enciende un LED durante medio       "|)
// (| " segundo, luego lo apaga durante medio segundo, indefinidamente,    "|)
// (| " con una Raspberry Pi Pico W y el lenguaje de programacion C++.     "|)
// (| "                                                                    "|)
// (| " La Raspberry Pi Pico W tienen un <LED_BUILTIN> integrado que puedes"|)
// (| " controlar solo por WiFi, ya que se maneja a través de llamadas API "|)
// (| " al controlador CYW43 y está conectado al pin WL_GPIO0.             "|)
// (| "                                                                    "|)
// (| " Este código de ejemplo es de dominio público.                      "|)
// (| "                                                                    "|)
// (| " Maker/Developer: jorgechac© - Técnico Laboral en Programación UNAB "|)
// (| " Visita https://jorgechac.blogspot.com                              "|)
// (| "                                                                    "|)
// (| " Venta de accesorios Arduino/Raspberry Pi Pico/ESP32                "|)
// (| " Whatsapp y Ventas NEQUI +573177295861                              "|)
// (| " Bucaramanga - Colombia                                             "|)
// (| "                                                                    "|)
// (| " Simulación: https://wokwi.com/projects/373639443546024961          "|)
// (| " Repositorio https://github.com/jorgechacblogspot/micropython_pico  "|)
// (| " https://jorgechac.blogspot.com/2021/04/raspberry-pi-pico-pin-mapping.html "|)
// ----------------------------------------------------------------------------------
#include <stdio.h>            // Incluye la biblioteca para funciones de entrada/salida estándar
#include "pico/stdlib.h"      // Incluye la biblioteca para las funciones estándar de la Raspberry Pi Pico W
#include "pico/cyw43_arch.h"  // Incluye la biblioteca para funcionalidad de la interfaz Wi-Fi

// Declaración de la función printf
int printf(const char* format, ...);

// Se inicializa la biblioteca de entrada/salida estándar utilizando stdio_init_all().
// Luego, intenta inicializar la interfaz Wi-Fi con cyw43_arch_init(). Si la inicialización
// de Wi-Fi falla, se imprime un mensaje de error y el programa retorna -1.

int main() {
  stdio_init_all();
  if (cyw43_arch_init()) {
    printf("Error al iniciar Wi-Fi");
    return -1;
  }

// En el bucle infinito while (1), el programa alterna el estado del LED_BUILTIN. Utiliza
// la función cyw43_arch_gpio_put() para encender el LED estableciendo el pin CYW43_WL_GPIO_LED_PIN
// en 1, espera 500 milisegundos con sleep_ms(500), apaga el LED estableciendo el pin en 0 y espera
// otros 500 milisegundos, antes de repetir el proceso indefinidamente:

  while (1) {
    cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
    sleep_ms(500);
    cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
    sleep_ms(500);
  }
}
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS