-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
41 lines (36 loc) · 1.45 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*****************************************************************************************************************************
********************************** Author : Ehab Magdy Abdullah *************************************
********************************** Linkedin: https://www.linkedin.com/in/ehabmagdyy/ *************************************
********************************** Youtube : https://www.youtube.com/@EhabMagdyy *************************************
******************************************************************************************************************************/
/********************************* Copy This those sections in your code ************************************/
/* USER CODE BEGIN Includes */
#include "ultrasonic.h"
/* USER CODE END Includes */
/* USER CODE BEGIN PV */
uint16_t distance;
uint8_t isReadingFinished = 0;
/* USER CODE END PV */
int main(void)
{
/* USER CODE BEGIN 2 */
HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_1);
Ultrasonic_Get_Distance();
HAL_Delay(20);
/* USER CODE END 2 */
/* USER CODE BEGIN WHILE */
while (1)
{
if (isReadingFinished)
{
isReadingFinished = 0;
// if(distance < 10 && distance > 0)
// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
// else
// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET);
HAL_Delay(20);
Ultrasonic_Get_Distance();
}
/* USER CODE END WHILE */
}
}