The time-dependent Schrödinger equation with piecewise constant potentials