What you are asked to make is a breathing light.
You should implement the tasks below one by one, and submit the change that achieve the most functions! (Only fulfill the first task is good enough)
-
Use a switch(output 0 when closed, 1 when open!!!!!) to control the on/off of the light
(About where you can find the labels:
-
The two pdf files and also the developing board itself.
You should find the label of the switch and the LED yourself. If you cannot find them, you can ask me for help. Apologies that some materials are not in Chinese.)
-
-
Make the light that will be connected to
PB11
to breath periodically(The mechanism of breathing light is change the pulse of PWM periodically.)
-
Make the period to be 2s (1s to brighten and 1s to darken)
-
2. Please take a short video of you demonstrating the function of your model. Upload you video here. The video should also name after you.
- use
HAL_Delay(time)
to keep the existing state of the developing board fortime
μs - HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_4);
- Do not mistake the concept of period of breathing light and period of PWM.
- Use
HAL_GPIO_ReadPin(GPIO_port, GPIO_PIN_id)
to read the pin. - There is no need to create any interrupt, just add your code in the while loop inside
main()
- All the techniques you need is taught in the training, so those who didn't come please refer to the slide and video.
- You will never know what problems you will encounter if you don't practice those theories by yourself!
- Ask google or me if there's any uncertainty, my email's [email protected]