Development of a maze ball (gravity sensing Control) game based on the wild fire M3 Development Board (STM32F103VET6)

Source: Internet
Author: User


This is a major task of studying the "real-time embedded System experiment" course last semester. It is to use the resources of the wild fire board and add an AHRS (Attitude and Heading Reference System) module, use gravity sensing to control the ball moving forward in the maze.

Gravity sensor module.At first, I bought a firefire extension module, MMA7455 three-axis acceleration sensor, 36 RMB, and I2C bus.

The I2C1 (STM32F103VET6 has two hardware I2C, I2C1, and I2C2) is used in the related examples in the coupon routine. The test is available. But there was a problem with I2C1's PB6-I2C1SCL and PB7-I2C1The SDA two pins are occupied by the touch screen XPT2046 signal line (PB6: XPT2046-INT, PB7: XPT2046-CS), I2C2 always encounter errors, want to use software I2C, find some code on the internet, it was not successfully transplanted, so the MMA7455 you bought won't be available. The same group of students borrowed an AHRS module from the Senior Brother (introduced here). The core module is the STM32F103T8 module. After the program is installed, the module sends the calculated current pitch, rolling, heading, air pressure, and temperature data continuously through the serial port. It is sufficient for me to change the angle data (the angle and the angle) relative to the two axes, So I modified the sending protocol so that the module only sent the angle and the angle. The original data is displayed on the serial assistant and looks like a float, essentially a string. I don't need such a high precision, so I need to translate it into 8-bit integer data, and modified the sending frequency, about (using software latency) 5Hz. For convenience of debugging, when I sent the data of the AHRS module to the wild fire board through USART3, the wild fire Board forwards the data to the PC through USART1, which is displayed on the PC serial port assistant. Receive available USARTReceiveData () is complete. Send the available library function USART.SendData () is complete. Be sure to wait until the sending is complete before proceeding to the next step. Otherwise, errors may occur and the data sent and received are all uint16.T type.

A = USARTReceiveData (USART3); '// receives data 

While (USART 
GetFlagStatus (USART1, USARTFLAG_TC) = RESET); '// wait until the sending is complete 

Firefire BoardWe use USART1 and USART3. the touch screen, SD card, file system, and font of Chinese characters are modified according to the routine of the fire. Place the background image in the SD card in BMP format. When displaying different images and jumping in or out of the loop, be sure to reset the positions such as the touch flag.

PS: The pictures displayed during game preparation and completion are made by a female in the group using PhotoShop. I really feel pretty. I can't do it anyway ......

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.