Often, nowadays, as you have drawn, the easiest answer is a microcontroller, but this requires software rather than hardware. This is not so difficult, but a different skillset.
A purely hardware solution might be quite complicated, but microcontrollers tend to be very flexible and with many...