Lab 1: LED Animations
Overview​
The first lab introduces the full toolchain: create an STM32Cube project, simulate it in Proteus, and drive LEDs from the STM32F103C6. You start from a single blinking LED and build up to traffic lights, a 7-segment display and a 12-LED analog clock.
Objectives​
- Create and configure an STM32Cube project; generate code and export a
.hex. - Build and run a Proteus simulation with the STM32F103C6.
- Control GPIO outputs:
HAL_GPIO_TogglePin/HAL_GPIO_WritePin,HAL_Delay.
Hardware & Tools​
- STM32F103C6, LED-RED / LED-YELLOW / LED-GREEN,
7SEG-COM-ANODE, resistors. - PA5 is wired to the on-board LED; for the 7-segment, segments connect to PB0–PB6 (active-low: a segment turns on when the pin is logic 0).
while (1) {
HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
HAL_Delay(1000); // blink every 1s
}
Exercises​
- Two LEDs (PA5/PA6) toggling every 2 s.
- A single-direction traffic light (red 5 s, yellow 2 s, green 3 s).
- A 4-way traffic light with 12 LEDs.
display7SEG(int num)— show digits 0–9 on one 7-segment.- Integrate the 7-segment as a countdown for the 4-way traffic light.
- A new schematic with 12 LEDs arranged as an analog clock (PA4–PA15).
clearAllClock()— turn off all 12 clock LEDs.setNumberOnClock(int num)— light the LED for position 0–11.clearNumberOnClock(int num)— turn off the LED for position 0–11.- Integrate everything: show hour/minute/second with 3 lit LEDs.
Report & Submission​
For each exercise, capture the Proteus schematic and present your source code (the while
loop and any helper functions). Submit on BKeL.