bouffalolab #41
tianrking
started this conversation in
Show and tell
Replies: 2 comments
-
bl602 AI-WB2-32S make CHIP=bl602 BOARD=bl602dk make flash CHIP=bl602 COMX=/dev/ttyUSB0 ① #include <stdio.h>
#include "bflb_gpio.h"
#include "bflb_mtimer.h"
#include "board.h"
#define LED_RED_PIN 14 // IO14
#define LED_GREEN_PIN 17 // IO17
#define LED_BLUE_PIN 3 // IO3
struct bflb_device_s *gpio;
void gpio_init(void)
{
gpio = bflb_device_get_by_name("gpio");
// 配置 GPIO 为输出模式
bflb_gpio_init(gpio, LED_RED_PIN, GPIO_OUTPUT | GPIO_PULLDOWN | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_init(gpio, LED_GREEN_PIN, GPIO_OUTPUT | GPIO_PULLDOWN | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_init(gpio, LED_BLUE_PIN, GPIO_OUTPUT | GPIO_PULLDOWN | GPIO_SMT_EN | GPIO_DRV_0);
// 初始状态设为低电平(LED关闭)
bflb_gpio_reset(gpio, LED_RED_PIN);
bflb_gpio_reset(gpio, LED_GREEN_PIN);
bflb_gpio_reset(gpio, LED_BLUE_PIN);
}
void set_led_color(uint8_t r, uint8_t g, uint8_t b)
{
// 高电平点亮LED
if (r) bflb_gpio_set(gpio, LED_RED_PIN); else bflb_gpio_reset(gpio, LED_RED_PIN);
if (g) bflb_gpio_set(gpio, LED_GREEN_PIN); else bflb_gpio_reset(gpio, LED_GREEN_PIN);
if (b) bflb_gpio_set(gpio, LED_BLUE_PIN); else bflb_gpio_reset(gpio, LED_BLUE_PIN);
}
int main(void)
{
board_init();
gpio_init();
printf("BL602 RGB LED GPIO 控制开始\r\n");
while (1) {
// 红色
set_led_color(1, 0, 0);
printf("红色 LED 亮起\r\n");
bflb_mtimer_delay_ms(1000);
// 绿色
set_led_color(0, 1, 0);
printf("绿色 LED 亮起\r\n");
bflb_mtimer_delay_ms(1000);
// 蓝色
set_led_color(0, 0, 1);
printf("蓝色 LED 亮起\r\n");
bflb_mtimer_delay_ms(1000);
// 白色 (所有 LED 亮起)
set_led_color(1, 1, 1);
printf("白色 (所有 LED 亮起)\r\n");
bflb_mtimer_delay_ms(1000);
// 紫色 (红+蓝)
set_led_color(1, 0, 1);
printf("紫色 LED 亮起\r\n");
bflb_mtimer_delay_ms(1000);
// 黄色 (红+绿)
set_led_color(1, 1, 0);
printf("黄色 LED 亮起\r\n");
bflb_mtimer_delay_ms(1000);
// 青色 (绿+蓝)
set_led_color(0, 1, 1);
printf("青色 LED 亮起\r\n");
bflb_mtimer_delay_ms(1000);
// 关闭所有 LED
set_led_color(0, 0, 0);
printf("所有 LED 关闭\r\n");
bflb_mtimer_delay_ms(1000);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
bl616 AI-M62-32S
make CHIP=bl616 BOARD=bl616dk
make flash CHIP=bl616 COMX=/dev/ttyUSB0
RGB light(red light connect to IO1,green light connect IO30,blue light connect
toIO0)
② Reset buttom
③ White light (IO 29)
④ Warm light (IO 27)
⑤
Burning key. When burning, it is necessary to press the burn key and reset key
successively, and then release the reset button and burn key successivel
https://docs.ai-thinker.com/_media/en/ai-m62-32s-kit_v1.0.0_specification-20230417.pdf
Beta Was this translation helpful? Give feedback.
All reactions