Skip to main content

Section D.3 Building and Running Blinky

We are now ready for Blinky! You are about to make the on-board LED on your Nucleo, which is connected to D13 (PA5), blink for the first time. This is the “hello, world” of embedded system programming. Have your Nucleo, its USB cable and a USB adapter (if your laptop needs one) ready. Do not plug the board in yet.
  1. In the Project Explorer, right-click on TemplateProject and select Copy.
  2. Right-click again (on TemplateProject), select Paste, type in Blinky for the project name and click Copy.
    Copy Project popup with Blinky typed as the project name, Use default location checked, the Location field blanked out, and Cancel and Copy buttons.
    Figure D.3.1. The Copy Project popup with Blinky entered as the project name. Keep Use default location checked, so that the copy goes into your workspace folder; the Location field is blanked out here.
  3. Download blinky.c (be sure to use the download option, not the open in the browser option) and find the downloaded file on your hard drive. Copy the file (right-click in your file browser and select Copy, or use the keyboard shortcut), return to the IDE and paste the file from your clipboard into the Src folder in the Blinky project. This is what you should now have:
    Project Explorer showing the Blinky project with Src expanded to blinky.c, syscalls.c and sysmem.c, and TemplateProject below it.
    Figure D.3.2. The Blinky project in the Project Explorer, with blinky.c in its Src folder beside syscalls.c and sysmem.c.
  4. Select your Blinky project and right-click. Select Close Unrelated Project from the context menu.
  5. Double-click on blinky.c to open the source code in the IDE.
  6. Build the project using the hammer symbol on the top menu bar (Figure D.3.3).
    STM32CubeIDE toolbar strip with the hammer-shaped Build button and the green Run button each circled in red.
    Figure D.3.3. The top menu bar of STM32CubeIDE. The Build button (a hammer) is circled on the left and the Run button (a green circle with a white triangle) on the right. The hammer is grayed out here only because no project was open when the screenshot was taken.
  7. Plug your Nucleo into an empty USB port on your computer. Upload and run the Blinky code using the Run button on the top menu bar.
  8. If you see a warning about updating the firmware of the ST-LINK, the programmer and debugger built into your Nucleo board, follow the instructions in Subsection D.4.1. If you see a message that ST-LINK Server is required, follow the instructions in Subsection D.4.2.
  9. In the popup about the launch configuration, accept the defaults.
Congratulations: you made it! Watch the on-board LED blink!