yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
STM32-BoardCar📖
0. Get started quickly
  • 0.ReadMe
  • 1. Installation Instructions
  • 2. Version configuration
  • 3. Smart car installation video
  • 4. Precautions for use
1. Introduction to STM32 development board
  • 1. Learn about STM32
  • 2. Introduction to STM32 development board
  • 3. Development board pin assignment
  • 4. Introduction to HAL library and LL library
2. Setting up and using the development environment
  • 1. Common development tools
  • 2. STM32CubeMX Install - Use
  • 3. STM32CubeIDE Install - Use
  • 4. Common Driver Installation
  • 5. Program download and simulation
  • 6. Engineering experience and migration
3. Development board basic tutorial
  • 1. RGB searchlight (GPIO)
  • 2. Buzzer control (GPIO)
  • 3. Button control (EXTI)
  • 4. Serial communication (UASRT)
  • 5. Voltage detection (ADC)
  • 6. Internal temperature sensor(ADC)
  • 7. Independent watchdog(IWDG)
  • 8. Window watchdog(WWDG)
  • 9. Basic timer (TIM6)
  • 10. Universal Timer (TIM3)
  • 11. Advanced timers (TIM1)
  • 12. I2C Communication (IIC)
  • 13. Off-chip Flash (SPI)
  • 14. On-chip Flash (Flash)
  • 15. DMA:USART
  • 16. DMA:SPI
  • 17. DMA:I2C
  • 18. USB communication
  • 19. USB analog U disk
  • 20. FreeRTOS
4. Car expansion tutorial
  • 1. Servo control
  • 2. Basic use of ultrasonic steering gear gimbal
  • 3. Motor control
  • 4. OLED display light sensitivity value
  • 5. Infrared sensor
  • 6. Four-way tracking module
  • 7. Infrared remote control
  • 8. Ultrasonic ranging
  • 9. PS2 controller test
  • 10.K230 Vision Module
  • 11.AI voice interaction integration module
5. Robot car tutorials
  • 1. Car line patrol
  • 2. Ultrasonic follow
  • 3. Ultrasonic obstacle avoidance
  • 4. Ultrasonic obstacle avoidance (servo gimbal version)
  • 5. Infrared sensor obstacle avoidance
  • 6. Infrared remote control
  • 7. PS2 handle remote control
  • 8.K230 face tracking on PTZ
  • 9.K230 color tracking
  • 10.K230 Color Line Patrol
  • 11.K230 QR code command
  • 12.K230 machine code tracking
  • 13.K230 road sign indication action (voice)
  • 14.K230 color response (voice)
  • 15.K230 gesture control (voice)
  • 16.K230 Rock-Paper-Scissors Game (Voice)
6. Operation video
  • 1-How to install STM32CubeIDE software
  • 2-How to create Demo project
  • 3-How to download code into STM32 robot car
  • 4-How to open and compile a code file for STM32
  • 5-About IR control and Charge battery
Download
  • Code
  • SCH
  • Software File
  • STM32 Chip DataSheet
  • Installation manual
Download ZIP

Welcome to STM32-BoardCar repository

1. RGB searchlight (GPIO)

RGB searchlight (GPIO)

RGB searchlight (GPIO)1. Software-Hardware2. Brief principle1. Hardware schematic diagram2. Physical connection diagram3. Control principle3. Engineering experienceOpen project4. Project configuration1. New project2. chip selection3. Project settings4. Pin configuration5. Clock configuration6. Project configuration7. Generate code5. Main functions1. User function2. HAL library function parsing6. Program download1. Serial port download2. ST-Link Download7. Experimental Phenomenon

This tutorial demonstrates: controlling the onboard RGB searchlight on the development board through the output function of GPIO.

The first tutorial in this chapter will be more detailed than the following tutorials. The purpose is to demonstrate from the new project to the complete effect, and guide users how to use STM32CubeIDE to develop

1. Software-Hardware

  • STM32F103CubeIDE

  • STM32 Robot Development Board

    GPIO: chip internal peripherals

    RGB searchlight: onboard

  • Type-C data cable or ST-Link

    Download programs or simulate the development board

2. Brief principle

1. Hardware schematic diagram

image-20230925153122335

2. Physical connection diagram

image-20231014152944153

3. Control principle

By controlling the high and low levels of the RGB light pins, the color displayed by the RGB light is controlled.

RGB: High level lights up, low level turns off

RGB(原理图名称)控制引脚功能
LRGB-RPG1Control the red light display of the left RGB light
LRGB-GPE7Control the green light display of the left RGB light
LRGB-BPG2Control the blue light display of the left RGB light
RRGB-RPE2Control the red light display of the RGB light on the right
RRGB-GPE3Control the green light display of the right RGB light
RRGB-BPE4Control the blue light display of the right RGB light
xxxxxxxxxx
RGB lights can display other colors by combining different brightnesses of the three basic colors of red, green, and blue.

3. Engineering experience

You can use the project files we provide to directly experience the corresponding functions of the development board.

Later tutorials do not provide this content to avoid duplication of content. You can go to [2. Development environment construction and use: engineering experience and transplantation] to view the operation

Open project

  • Project file location

    Project file path: Under the [Project Source Code] folder of the Chapter 3 tutorial

image-20231128154337644

  • Open project file

    Copy the project file to the directory of English path, use STM32CubeIDE to open the project file, open the project file and select the .project file

image-20231012221542861

xxxxxxxxxx
Tip: You can create a new STM32 folder on the desktop and select the STM32 folder as the workspace when opening the project file.

4. Project configuration

This tutorial will completely demonstrate the configuration process. Later, the content of new project, chip selection, project settings, pin settings of SYS, RCC configuration, clock configuration and project configuration will be omitted. Any changes will be stated in the tutorial. .

1. New project

  • Select workspace

    The path of a new project or the path of an existing project file: the path cannot contain Chinese characters

image-20230925203152690

  • New Project

image-20230925203837627

2. chip selection

image-20230925204025253

3. Project settings

  • project name

image-20230925205231299

  • Firmware version

image-20230925205412520

image-20230925205504890

4. Pin configuration

  • SYS

image-20230926101054492

  • RCC

image-20230926100816764

  • Configure specified pin function

You can directly select the corresponding pin number in the pin view, and the corresponding options will appear when you left-click the mouse.

image-20231028230352332

  • GPIO

image-20230926100744845

xxxxxxxxxx
Please refer to the figure above for specific configuration options. It is recommended to add tags. STM32CubeIDE will generate corresponding macro definitions.

5. Clock configuration

image-20230926101233831

xxxxxxxxxx
Refer to the options covered by the red arrows

6. Project configuration

  • Project

    do not need to change

image-20230926101326286

  • Code Generator

image-20230926101503107

  • Advanced Settings

    do not need to change

image-20230926101441819

7. Generate code

  • Click on the "pinion" icon

image-20230926101946427

xxxxxxxxxx
Click here to save or the Ctrl+C shortcut key to generate code.
  • Edit code

    The user code must be located between USER CODE BEGIN and USER CODE END.

image-20230926102446028

The above is the peripheral configuration and initialization code generation.

5. Main functions

It mainly introduces the functional code written by the user. For detailed code, you can open the project file provided by us yourself and enter the Bsp folder to view the source code. **

1. User function

function:BSP_Init

function prototypevoid BSP_Init(void)
Function descriptionInitialize the underlying/peripheral driver
Input parametersnone
return valuenone

function:BSP_Loop

function prototypevoid BSP_Loop(void)
Function descriptionLow-level/peripheral loop functions
Input parametersnone
return valuenone

function:Set_color_R

function prototypevoid Set_color_R(RGB_Color color)
Function descriptionDemonstration of setting up the RGB light display on the right
Input parameterscolor: Set RGB light color
return valuenone

function:Set_color_L

function prototypevoid Set_color_L(RGB_Color color)
Function descriptionDemonstration of setting up the RGB light display on the left
Input parameterscolor: Set RGB light color
return valuenone

function:Set_RGB

function prototypevoid Set_RGB(car_RGB light,RGB_Color color)
Function descriptionSet the color displayed by the left and right RGB lights
Input parameters 1light: Set the displayed RGB light
Input parameters 2color: Set RGB light color
return valuenone

2. HAL library function parsing

Since using STM32CubeIDE will automatically generate initialization code, only the HAL library functions involved in this tutorial are introduced here.

xxxxxxxxxx
If you want to find the HAL library and LL library function analysis involved in the entire tutorial, you can view the documents in the folder [8. STM32 Manual: STM32F1_HAL Library and LL Library_User Manual]

function:HAL_GPIO_Init

function prototypevoid HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
Function descriptionInitialize GPIO pin parameters
Input parameters 1GPIOx: Set the GPIO port, x takes the value A, B, C, D, E, F, G
Input parameters 2GPIO_Init: GPIO initialization structure
return valuenone

function:HAL_GPIO_WritePin

function prototypevoid HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
Function descriptionSet/Clear the specified data port bit
Input parameters 1GPIOx: Set the GPIO port, x takes the value A, B, C, D, E, F, G
Input parameters 2GPIO_Pin: Set GPIO pin, x value is 0-15
Input parameters 3PinState: Bit_RESET: clear the data port bit (low level); Bit_SET: set the data port bit (high level)
return valuenone

function:HAL_Delay

function prototypevoid HAL_Delay(uint32_t Delay)
Function descriptionDelay for a certain period of time
Input parametersDelay: Set the delay in milliseconds
return valuenone

6. Program download

1. Serial port download

  • Generate .hex file: Left-click the project → select "Properties"

image-20230926103920517

  • Check the corresponding option

image-20230926104047714

image-20230926104154963

xxxxxxxxxx
hex file location: under the Debug folder of the project file
  • Program Download

    Use the Type-C data cable to connect the development board and computer. For more detailed programming procedures, please refer to [2. Development environment construction and use: program download and simulation]

image-20230926105354332

xxxxxxxxxx
Pay attention to the contents selected in the red box, which must be consistent

2. ST-Link Download

  • Debug Settings: ST-Link → SWD

image-20230926140654072

image-20230926140817968

  • Program Download: Click the Debug icon

image-20230926140948781

7. Experimental Phenomenon

After downloading the program successfully, press the RESET button of the development board and observe the development board phenomenon!

xxxxxxxxxx
For program download, please refer to [2. Development environment construction and use: program download and simulation]

Phenomenon:

The RGB light on the right turns red for 0.2 seconds and turns off for 0.2 seconds;

The RGB light on the left turns green for 0.2 seconds and turns off for 0.2 seconds;

The RGB lights on the left and right sides turn purple for 0.2 seconds and turn off for 0.2 seconds;

You can see the experimental phenomenon [RGB Searchlight_Experimental Phenomenon.mp4]
Engineering experience and migration
Buzzer control (GPIO)

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文