Skip to content

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 ​

Snipaste_2024-09-01_15-39-40.png 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. Snipaste_2024-09-01_15-40-20.png That's it — the flashing is complete. Snipaste_2024-09-01_15-40-29.png Manually reset the board.

Observe the Result ​

GIF2024-9-115-52-11.gif 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.

Released under the MIT License. Build Time 2026-09-30 17:31:25