Contributed by bzhou830, organized by Ai-Thinker
[Ai-WB2] Easy Peasy: Lighting Up the WB2
[Ai-WB2] Easy Peasy: Setting Up the Development Environment under WSL Last time we set up the development environment. This time, let's light up an LED.
Prepare the Code
The code is already in the ~/Ai-Thinker-WB2/applications/get-started/blink directory. Just use it directly.
Click to expand full code
cpp
#include <stdio.h>
#include <string.h>
#include <FreeRTOS.h>
#include <task.h>
#include <bl_gpio.h>
#define GPIO_LED_PIN 3
void blink_test(void *param)
{
uint8_t value = 1;
while (1)
{
bl_gpio_enable_output(GPIO_LED_PIN, 0, 0);
printf("Turning the LED %s! \r\n", value == 1 ? "ON" : "OFF");
bl_gpio_output_set(GPIO_LED_PIN, value);
value = !value;
vTaskDelay(1000);
}
void main(void)
{
xTaskCreate(blink_test, "blink", 1024, NULL, 15, NULL);
}Compile and Flash
To flash, you first need to put the WB2 into flashing mode: hold down the BOOT key without releasing it, then press RST. Press RST again when prompted to do so.
That's it — the flashing is complete.
Manually reset the board.
Observe the Result
Done, simple as that!
[Ai-WB2] Easy Peasy: Setting Up the Development Environment under WSL
Last time we set up the development environment. This time, let's light up an LED.

