-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton
More file actions
72 lines (60 loc) · 1.26 KB
/
Button
File metadata and controls
72 lines (60 loc) · 1.26 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
uint16_t Timer = 0;
uint8_t pull = 0;
uint8_t Counter = 0;
uint8_t Pression = 0;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
Pression = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13);
if(Pression == 1)
{
if (pull == 0)
{
Counter = Counter + 1;
pull = 1;
}
Timer = 0;
}
else
{
pull = 0;
Timer = Timer + 1;
}
if(Timer == 1024)
{
for(int i = 0; i < Counter; i = i + 1)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
HAL_Delay(100);
}
Counter = 0;
Timer = 0;
}
HAL_Delay(1);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}