This is the firmware repository for the DIY Money Counting Machine. Initially it was a uni project, but I decided to improve it by separating the project architecture into generic core and board specific code, which allowed easy-porting on other boards, such as RP Pico 2W, by just writing the initialization file and wrapping the tasks.
The user would place a stack of banknotes into the dedicated compartment. Then they would input the value of one banknote. After pressing the start button, the motor would pull the bottom banknote into a narrow slit, then, employing the gravity, the banknote would trigger the beam interrupt sensor, thus, increase the counter. If after a certain amount of time nothing triggers the sensor, the motor would stop. The front panel would feature the display, which would show the total sum along with the current value of one banknote; and a bunch of buttons, such as start, clear (set the counter and sum to 0), number inputs and preset banknote values (10/20/50/100 etc).
The sensor has 3 terminals: Vcc, GND and OUT. OUT is high by default, and the sensor pulls it low only if there is something on the way of the beam (e.g. banknote). The motor pulls the banknotes, the board counts them, the display shows the sum to the user, that's it
Flying banknote hits the plastic pendulum (aka mechanical flag), which unblocks the beam for a short moment, creating a rising edge that gets processed by the microcontroller.
After final assembly, the machine looks like this:

The project source is structured in a following way:
core/... --> The main logic, board-independent
stm32/... --> Initialization for Nucleo U545RE_Q board (the original version of the project)
rp_pico_2w/... --> Initialization for RP Pico 2W board
The schematics are available at board-specific directories.
Along with basic some electronic components (wires, resistors, capacitors etc.) and tools (soldering iron, glue gun etc.). The estimated cost if the project is around ~50 EUR for the STM version, and around ~35 EUR for the RP version.
