Of course we all use different boards for different projects but there is something special about the Arduino UNO: it has the perfect size for prototyping, it’s easy to read pin labels, has many shields to choose from and now UNO R4 added power and exciting features to the mix.
I wanted to make a project for UNO R4 to challenge the backward compatibility and also to test the performance, and I came out with the idea of a soccer prediction device with an LCD keypad shield designed for the original UNO.
Why soccer? Because it is a beautiful sport. Also and unrelated I’m Agentinian :)
In any case the same project could be easily adapted to any other sport as long as you have an historic database of matches with useful information to extract.
Data is the foundation of Machine Learning, so I was prepared to spend some time here. I was able to locate a matches database from the FIFA. Using Python I had to assign ID to countries and delete not relevant data. I left just a few columns since at execution almost the same info should be entered with 5 buttons to make inferences.
For Machine Learning I did use Edge Impulse platform, which is free for developers and provides many features that simplifies the entire ML cycle.
I have used a classification algorithm and I’ve got a 69% accuracy. Not great but since my objective here were was to test UNO R4 features and no sensitive action was to be performed, I did not went further. Adding some extra columns and leaving matches from the latest years could increase accuracy.
Soccer Prediction project in Edge Impulse
Arduino DeploymentEven when UNO R4 is not a supported board, I was able to make a deployment as a generic Arduino library, which provides example code to make inferences from sensors or to manually specify an array of features. Using that code as the starting point, I have integrated the Shield.
Download the soccer2.ino and the ML model from https://github.com/ronibandini/soccerForecast
Add https://downloads.arduino.cc/packages/package_UNOr4_earlyaccess_index.json to additional boards
Select R4, Renesas Boards
Finally, select the board and port.
Download DFRobot Library from https://img.dfrobot.com.cn/wiki/5ea64bf6cf1d8c7738ad2881/a1c0f8ffd360b58c495ab0c88050c65f.zip and Add as a Zip file
Open soccer2.ino and upload to the UNO R4 Minima.
Connect the Shield and you are done.
DFRobot LCD and Keypad shieldThe DFRobot library also came with an example of reading buttons and displaying info on screen. I have added countries as arrays adding FIFA rank, so that fixed value per team is not entered with the keypad.
int idCountries[] = {9, 42, 28, 215, 44, 77, 102, 136, 191, 214, 70};
String countries[] = {“Argentine”,”Chile”,”Brazil”, “USA”,”Colombia”,”Germany”,”Italy”,”Mexico”,”Spain”,”England”,”France”};
int fifaRank[] = {1, 31, 3, 13, 17, 14, 8, 15, 10, 5, 2};
Then I have requested home team, away team and neutral location. Inserted those values in the array and called the inference.
for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
ei_printf(" %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);
if (result.classification[ix].label=="win"){
clearScreen();
lcd.setCursor(0, 0);
lcd.print(countries[indexCountry1]+"-"+countries[indexCountry2]);
lcd.setCursor(0, 1);
lcd.print("Home win "+String(result.classification[ix].value*100)+"%");
delay(5000);
neutralLocation=0;
clearScreen();
lcd.setCursor(0, 0);
lcd.print("Select home team");
}
Final notes
The shield, even having 2 parts: buttons and LCD was integrated without any complication. The library worked and I did not have to modify any setting. It is important to note that the Shield does not goes all the way down. Pins will make top with almost 3mm free.
The Machine Learning algorithm runs over the Arduino UNO R4 Minima as fast as it was a function call to print a debug message through Serial and the library downloaded from Edge Impulse worked perfectly, without any memory or settings to change.
Having worked in many different projects over the last years and having used official and clones boards from many companies, it is clear to me that an original Arduino stands out in quality and reliability.
It is important to note that UNO R4 is not just a matter of performance, it has many interesting features. For example: 12 bit DAC for audio output, CAN bus to integrate with vehicles, daisy chain for sensors and peripherals, on board led matrix for the WiFi version and more, so again: imagination is the limit.
Demo
View also
Comments