Firmware
Figure 1: Final assembly
Moving into the field of firmware, the STM32 is a very powerful board that many hobbyists use. It also has an intuitive and easy-to-use IDE which makes this simpler. I made this project to learn how this IDE works and the best way to go about using an STM microcontroller. I was able to develop a program that would act as a dice and illuminate the relevant LED for each number rolled. I achieved this using one of the onboard timer counters (T/C). I set the T/C to increment in time with the system clock, counting from 0 to a max value of 5. This allowed for six different possible values of the T/C at any given time. With the random values ready, I simply had to read the current value of the T/C every time the user pressed the onboard button and write this output to the LEDs depending on the values.
The first thing I learned very quickly was how important it is to read a datasheet fully before purchasing a piece of hardware. This came to my attention as I was trying to implement a randomly generated number (RNG) in my code. Some STM32 boards come with an RNG register. This is a 32-bit register that is filled with electrical noise, allowing for easy access to random numbers. The board that I got did not have one of these registers. Aside from that, I mostly just learned how the IDE of the STM32 works and became more comfortable working with them and microcontrollers in general.
A future inspiration that I gained from this project was simply that I wanted to do more work with the STM32 controllers in the future and, ideally do a more complex project that will allow me to push the STM32 to its limits.