User LD2: the green LED is a user LED connected to Arduino signal D13 corresponding to
MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on the STM32 target. Please refer to
Ta bl e 10 to Table 21.
• When the I/O is HIGH value, the LED is on.
• When the I/O is LOW, the LED is off.
在自动生成的项目文件中,找到main.c 并添加如下代码,功能是点亮LD2。
/* USER CODE BEGIN 2 */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
/* USER CODE END 2 */
/* USER CODE BEGIN 3 */
/* Infinite loop */
while (1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
HAL_Delay(500);
}
/* USER CODE END 3 */