STM32F103 Nucleo-F103 Shield Bd : GPIO LED on/off
페이지 정보
작성자 최고관리자 작성일20-05-08 18:35 조회7,986회 댓글1건첨부파일
- GPIO_LED_ONOFF.mp4 (2.7M) 22회 다운로드 DATE : 2020-05-08 18:35:14
관련링크
본문
** ST 보드명 : Nucleo-F103RB
** Zeus 보드명 : Nucleo 64 shield Bd V1.0
** 주요함수 및 Source Code
void LED_RGB_OnOff(char LED, char status, char duration)
{
switch( LED )
{
case 'R':
if( status ==1) { HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET); HAL_Delay(duration); }
if( status ==0) { HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_RESET); HAL_Delay(duration); }
break;
case 'G':
if( status ==1) { HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_SET); HAL_Delay(duration); }
if( status ==0) { HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_RESET); HAL_Delay(duration); }
break;
case 'B':
if( status ==1) { HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_SET); HAL_Delay(duration); }
if( status ==0) { HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_RESET); HAL_Delay(duration); }
break;
}
}
char timedelay= 100;
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
LED_RGB_OnOff( 'R',1, timedelay);
LED_RGB_OnOff( 'R',0, timedelay);
LED_RGB_OnOff( 'G',1, timedelay );
LED_RGB_OnOff( 'G',0, timedelay);
LED_RGB_OnOff( 'B',1, timedelay);
LED_RGB_OnOff( 'B',0, timedelay);
}
/* USER CODE END 3 */
}
** Zeus 보드명 : Nucleo 64 shield Bd V1.0
** 주요함수 및 Source Code
void LED_RGB_OnOff(char LED, char status, char duration)
{
switch( LED )
{
case 'R':
if( status ==1) { HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET); HAL_Delay(duration); }
if( status ==0) { HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_RESET); HAL_Delay(duration); }
break;
case 'G':
if( status ==1) { HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_SET); HAL_Delay(duration); }
if( status ==0) { HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_RESET); HAL_Delay(duration); }
break;
case 'B':
if( status ==1) { HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_SET); HAL_Delay(duration); }
if( status ==0) { HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, GPIO_PIN_RESET); HAL_Delay(duration); }
break;
}
}
char timedelay= 100;
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
LED_RGB_OnOff( 'R',1, timedelay);
LED_RGB_OnOff( 'R',0, timedelay);
LED_RGB_OnOff( 'G',1, timedelay );
LED_RGB_OnOff( 'G',0, timedelay);
LED_RGB_OnOff( 'B',1, timedelay);
LED_RGB_OnOff( 'B',0, timedelay);
}
/* USER CODE END 3 */
}
댓글목록
김희경님의 댓글
김희경 작성일좋은 정보 감사합니다.