stm32-ds18b20-Main-Program

by Marwen Maghrebi
int main(void) {
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_USART1_UART_Init();

    delay_us_dwt_init();  // Initialize the DWT for delays
    uartx_write_text(&huart1, "Initialization complete\r\n");

    while (1) {
        float temperature = DS18b20_temp();  // Get temperature
        char buffer[50];
        sprintf(buffer, "Temperature = %.2f°C\r\n", temperature);
        uartx_write_text(&huart1, buffer);  // Send temperature over UART
        HAL_Delay(800);  // Wait before next read
        HAL_GPIO_TogglePin(led_GPIO_Port, led_Pin);  // Toggle LED
    }
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00