Software apps and online services
Toy train has a long history and is a popular toy for children. Mickey rabbit small train track is compatible with IKEA's track, and children can't get tired of playing. However, after all, the electric small locomotive has only one speed, and the small locomotive drives the carriage forward at a constant speed for a long time, which is inevitably boring. How to enhance interest?
Train your own model through M5StickV and upload it to the server to get the returned training model. In this way, the small train is equipped with a pair of smart eyes that can recognize traffic signs.
Seven traffic signs have been trained in this project. I try to use it in the little track train, and use M5StickC as the executive component to build a funny track train based on visual recognition.
My idea is that such a small locomotive pulls a car and starts from the departure station, passing through seven actions: speed limit, pay attention to the train, release the speed limit, light up, whistle and stop. The small locomotive transforms into an AI small train that can recognize traffic signs. According to the traffic signs, it completes such actions as changing speed, flashing lights, honking various sound effects, starting and stopping. More fun for children's toys.
Use the training program of M5StickV to take more than 100 photos of each of the seven traffic signs (700 + photos in total) and send them to http://v-training.m5stack.com/. If your training meets the requirements, the calculation results will converge, so that in about half an hour, you will receive an email with a download link. After downloading, you will get an independent training model library and a boot.py demo code. Don't underestimate this demo, we will easily migrate it to the main program. Note: when training, try to put the model in the viewfinder and try different lighting conditions.
This part mainly sends the result of recognition to M5StickC, so UART sending programming is the main content. In addition, because m5sitckv has a horn, the train sound effect of our project is realized by M5SitckV, the locomotive light mentioned above is not on, and M5StickV itself has a very bright full-color LED, and the task of lighting is also handed to M5StickV.
The code of M5StickC is relatively simple. After receiving the recognition character from UART, the action behavior can be sent to L298N through a series of judgment statements.
When designing the code of M5SitckC, I use uiflow as the UI design and framework construction, and then use thorny to debug the generated code. Players may ask two questions here: first, why not continue debugging with UIFlow? After all, uiflow has some limitations, and thorny can get a very comprehensive debugging and error information when debugging ESP32. Second, why does not use Vscode + M5 plug-in when debugging M5StickC? Because the screen of M5StickC is very small, when debugging Vscode + M5 plug-in, no specific error information can be obtained. So according to my experience, when debugging M5StickC, the most suitable way for me is UIFlow + thorny IDE.
On the screen of M5StickC, I designed three parameters, one is the battery voltage (the endurance of C is weak, it is very important to display the battery voltage in real time, otherwise there will be a lot of trouble in debugging), the other is to display the identification feature code obtained from V, and the third is the action behavior of Real C (such as stop / go /...) to facilitate the understanding of the identification when it is in joint debugging with V.
In the joint commissioning, I used a small skill to weld the input wire end of a test motor with two DuPont wire bus heads, while the output and input copper wire ends of L298N were welded with pins and heat shrinkable. In this way, it is very convenient to connect L298N with battery, motor and M5StickC. In the formal deployment, only the copper conductor needs to be cut to the appropriate length. Such a small skill can greatly shorten the debugging time and increase the reliability of debugging. The purpose of L298N debugging is to test each control behavior and get PWM parameters according to the actual situation of the motor (this parameter will be modified after assembling the small locomotive motor).