I0718001 - Abraham Babtistio - SBM - Button
I0718001 - Abraham Babtistio - SBM - Button
I0718001 - Abraham Babtistio - SBM - Button
I0718001
NIM : I0718001
Rangkaian :
Kode Program :
***************************************************************************
* @file : main.c
* @brief : Main program body
***************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
Abraham Babtistio
I0718001
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
***************************************************************************
*/
/* USER CODE END Header */
/* Includes -------------------------------------------------------------*/
#include "main.h"
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* MCU Configuration---------------------------------------------------*/
/* Infinite loop */
Abraham Babtistio
I0718001
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
//Membaca input Pin BUTTON_LED
HAL_GPIO_ReadPin(GPIOA, BUTTON_LED_Pin);
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state
*/
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line
number,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file,
line) */
Abraham Babtistio
I0718001
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
Hasil Percobaan:
LED menyala
LED mati
Abraham Babtistio
I0718001
*/Catatan:
Karena terjadi bug pada proteus maka rangkaian dianggap menyala jika seperti ini
#include "main.h"
int main(void)
{
/* USER CODE BEGIN 1 */
/* MCU Configuration---------------------------------------------------*/
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
//Looping kode utama. Perintah dibawah akan
dieksekusi terus menerus oleh mikrokontroler.
//Membaca input Pin BUTTON_LED
HAL_GPIO_ReadPin(GPIOA, BUTTON_LED_Pin);
/**
* @brief System Clock Configuration
* @retval None
*/
Abraham Babtistio
I0718001
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
HAL_GPIO_Init(BUTTON_LED_GPIO_Port, &GPIO_InitStruct);
}