I wrote a program for the Arduino, and put together a test circuit to see if it would work. I used LEDs to show the functions. I wrote 6 different versions of the code until I finally came up with one that worked exactly how I wanted. I’m not a programmer, so this code is rather sloppy, and I’m sure there’s a much better way to do this, but, hey, it works.
I’ll post the code later, after I make the final version.