(I also forgot to add that I'm working on another version where you can change the code to your liking without placing torches!)
Okay, so it's quite simple! It's just some AND gates along with redstone torches on one side, as the input you need to do whatever you want it to do. The video explains a whole lot better, so go ahead and watch.
I also apologize if this has been done before, I just came up with this.