This project shows how to create a classic LED animation using the STM32F407-Discovery board. It lights up four LEDs in a sequence, mimicking the "Knight Rider" effect. The program is built with STM32CubeIDE and the HAL library. It demonstrates a basic approach where each LED is controlled with simple commands like HAL_GPIO_WritePin and HAL_Delay.
The animation works as follows:
- The LEDs light up from
PA1toPA4in order (moving right). - The LEDs then turn off in reverse order from
PA4back toPA1(moving left).
To get started with this project, follow these steps:
- Hardware: A computer with USB support.
- Software: You will need STM32CubeIDE installed on your system. Download it from the official STMicroelectronics website.
- Board: Ensure you have the STM32F407-Discovery board.
Go to the Releases page to find the latest version of the software.
Click on the latest release and download the ZIP file.
After downloading, locate the ZIP file and extract its contents to a folder on your computer.
- Launch STM32CubeIDE.
- Navigate to the folder where you extracted the files.
- In STM32CubeIDE, click on
File>Import. - Select
Existing Projects into Workspace. - Browse to the folder containing the extracted files and select it.
- Click
Finishto import the project.
- Right-click on the project in the Project Explorer.
- Select
Build Project. - Wait for the build to complete without errors.
- Connect the STM32F407-Discovery board to your computer via USB.
- In STM32CubeIDE, click on
Run>Debug. - Follow the prompts to upload the program to your board.
Once uploaded, the LEDs will automatically start animating. Watch the lights move back and forth!
- Control up to four LEDs.
- Simple commands to demonstrate basic programming concepts.
- Ideal for beginners interested in embedded systems and microcontrollers.
If you are interested in a more advanced version of this project that uses arrays and loops to reduce code repetition, check out the improved version here.
If you encounter any issues, please open an issue on the GitHub repository. We welcome feedback and contributions.
This project is licensed under the MIT License. See the LICENSE file for details.