From 49447b2738a874071a2a4bb61b3e0c2af6be989f Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 08 Oct 2025 19:31:43 +0800 Subject: [PATCH] WS2812B Led灯带程序 --- Core/Src/main.c | 32 +++++++++++++------------------- 1 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 281d186..6e3ad7a 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -18,11 +18,15 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" +#include "adc.h" +#include "tim.h" +#include "usart.h" #include "gpio.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "miscdev.h" +#include "ws2812b.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -86,33 +90,23 @@ /* Initialize all configured peripherals */ MX_GPIO_Init(); + MX_USART1_UART_Init(); + MX_ADC1_Init(); + MX_TIM6_Init(); + MX_TIM1_Init(); /* USER CODE BEGIN 2 */ - init_relay(); - init_led(); - /* Turn on relay after 1 second */ - HAL_Delay(1000); - turn_relay(Relay1, ON); + ws2812b_init(); + beep_start(2, 300); + /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { - /* Blink Red Led */ - turn_led(Led_R, ON); - HAL_Delay(200); - turn_led(Led_R, OFF); - HAL_Delay(200); - - /* Blink Green Led */ - toggle_led(Led_G); - HAL_Delay(200); - toggle_led(Led_G); - HAL_Delay(200); - - /* Blink Blue Led */ - blink_led(Led_B, 200); + /* Blink WS2812B strip lights */ + ws2812b_blink(); /* USER CODE END WHILE */ -- Gitblit v1.9.1