Page 452 - ARM Based Microcontroller Projects Using MBED
P. 452
438 17. STM32 NUCLEO EXPANSION BOARDS
17.20 PROJECT 5—MEASURING DISTANCE TO AN OBJECT USING
THE X-NUCLEO-53L0A1 EXPANSION BOARD
17.20.1 Description
In this project an X-NUCLEO-OUT01A1 expansion board is plugged on top of the Nucleo-
F411RE development board. The project measures the distance in millimeters to an object in-
front of the expansion board and displays the result on the PC screen.
17.20.2 Aim
This is a very simple project. The aim of this project is to show how the X-NUCLEO-
53L01A1 expansion board can be used in a project with a Nucleo development board.
17.20.3 Program Listing
Library Xnucleo53L01A1 must be downloaded to the program space before the board can
be used. This is available at the following website:
https://os.mbed.com/components/X-NUCLEO-53L0A1/
Create a new Mbed program, for example, called Sonar. Open the above website and click
Import Library. Then select Sonar by clicking on Target Path to download the library to your
program space. Fig. 17.34 shows the program listing. At the beginning of the program header
2
files mbed.h and XNucleo53L01A1.h are included in the program and the I C interface be-
tween the expansion board and the development board are defined. The program initializes
the expansion board and then enters an endless loop. Inside this loop the distance in-front of
the expansion board is measured and is displayed in millimeters on the PC screen. The loop
repeats after 1s delay.
A typical display from the program is shown in Fig. 17.35.
17.20.4 Suggestions for Additional Work
Modify the program in Fig. 17.34 to display the distance on the onboard LEDs (see the ex-
ample program in the X-NUCLEO-53L01A1 Mbed website).
17.21 SUMMARY
In this chapter we have learned about the following:
• Information on commonly used Nucleo expansion boards
• Measuring humidity, temperature, and atmospheric pressure using an expansion board
• Controlling the speed of a small brushed DC motor using an expansion board
• Using the industrial I/O expansion board in a project
• Using the ranging and gesture detection sensor expansion board in a project

