Code, usage notes for operation of an STM32-controlled "self-balancing car", as shown below:
There are several similar models available from different suppliers on AliExpress, BangGood etc.
The "open source" code was supplied by the vendor as a baidu link.
Link: https://pan.baidu.com/s/1M-D3hrumQRwJgep1K78iIw
Password: bx5w
The problem is you can't download from baidu without a baidu account, and you can't create a baidu account without supplying a Chinese phone number.
I previously made use of a workaround (https://oneleaf.icu/), but that no longer seems active, so I have uploaded the original supplied code to the download/ folder of this repository.
The code/ directory contains several versions of the project:
- Main
- DMP Version
- Complentary Filter Version
- Kalman Filter Version
- Simplified Beginner's Version
- Arduino Version
- Long press on USER button: toggle operation mode
- "putong" (普通) = "ordinary" (i.e. static balance)
- "bizhang" (蔽障) = "obstacle" (i.e. moves to avoid obstacles placed in front of ultrasonic sensor)
- Short press on USER button: start/stop balancing
- Pair with the BT04-A module (passcode 1234) to be able to send/receive data via BT Classic serial interface
- Connect an RC receiver (e.g. FS-iA6B) to the connector near the power with the BT04-A module (passcode 1234) to be able to send/receive data via BT Classic serial interface.
- The connector is a 4x3 block, with 4xGND, 4x5V, and GPIO pins PC6-PC9.
- 2x MG513P3012V Motors, 30:1 gear ratio
- Compile the Keil uVision project with CCD support contained in pid-balancecar\download\CCD Attachment\TSL1401线性CCD模块附送资料V3.1-202120217\2.平衡小车专用CCD巡线代码\2.STM32平衡小车 CCD巡线\CCD巡线代码【高配版平衡小车STM32F405RGT6】
- If required, install support for the STM32F405RGT6 board
- To upload the code (without using the STLink dongle), load the FlyMCU application.
- Set the COM port and bps:76800, then hit the big (P) button to program the board.


