This is the previous version, but with a simplification given by the use of the 7404 and 7408 circuits. The circuit must be powered by 5 V.