Turn LED on and off on homemade STM32F405 development board
I have a simple switch on an LED project on a homemade STM32F405 development board. I am using STM32 Cube-MX and It is all working OK and turns an LED on and off via a momentary switch on subsequent button presses. The problem is that on starting the program the externally connected LED starts off in the on state whereas I would like it to start in the off state. Here is the relevant section of my main.c code and I was wondering how I can change it to make this happen please? I am hoping that this code snippet is where it can be changed but I can post the whole main.c if required.
while (1)
{
// https://www.youtube.com/watch?v=sWe4kvzLMjY
if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3) && tempVar)
{
// wait 5 ms
HAL_Delay(5);
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
tempVar = false;
}
else if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3)==GPIO_PIN_RESET)
{
// wait 5 ms
HAL_Delay(5);
tempVar = true;
}