User Tools

Site Tools


No ACL setup yet! Denying access to everyone.
en:edu:zmitac:macro:embedeed:lab:stm32-gpio

This is an old revision of the document!


STM32 Control of build-in LEDs with buttons

This exercise presents how to control three LEDs with buttons mounted on the Nucleo STM32WB55 board.

Prerequisites

A good understanding of the digital GPIO pins operation and principles of interrupts is necessary. We use the Arduino Core STM32 framework (stm32duino)1) for STM32WB55. During this laboratory, no additional external libraries will be required for the project.

Background

LEDs and buttons are electrically connected to microcontroller's pins. Below we will show how they are connected because it determines their behaviour depending on the software.

LED connection

LEDs are electrically connected to microcontroller's pins. LEDs have 3 different colours (Red, Green, and Blue). The red LED is connected to the pin PB1, the green LED to the pin PB0, and the blue LED to the pin PB5. LED is lit when the pin state is “1”, and dark when the pin state is “0”. LEDs are easily accessible in the software as digital pins named LED_RED, LED_GREEN, and LED_BLUE respectively. Each LED can be controlled with the Arduino standard DigitalWrite() function to switch it on or off.  LEDs connection

Buttons connection

The buttons on board are named SW1, SW2, and SW3, and are connected to pins PC4, PD0, and PD1 respectively. In the software, the names of the pushbuttons are SW1_BTN, SW2_BTN, and SW3_BTN. Pushbuttons are easily accessible in the software by their names using the Arduino function DigitalRead(). Buttons are connected to the ground, so the reading gives the “0” state result if the button is pressed and the “1” state otherwise.  Buttons connection

Tasks to be implemented

1. Write the program that will switch the red LED for one second, then the green LED for one second, and the blue LED for one second repeatedly. Use the Delay() function. This part is to be familiar with the environment, GPIO controlling, and the STM32WB55 board.
2. Write the program that will light the blue LED when the SW1 button is pressed, green RED when SW2 is pressed and red LED when SW3 is pressed.

en/edu/zmitac/macro/embedeed/lab/stm32-gpio.1710688618.txt.gz · Last modified: by ktokarz