Anti-Black laws and ordinances depriving Blacks of their civil rights were passed in the ante-bellum North once slavery was outlawed in many states of the North and in states admitted to the Union as free states. Without the bonds of slavery to control the Black population, Whites figured they needed a kind of Black Code.
Once slavery was outlawed in the South, the same thing occurred; Black Codes were instituted to control this large population that before had been largely the responsibility of individual slave holders.
Now that Republicans, the inheritors of The Southern Way of Life, have seen the power of the Black vote to elect a president, they are rushing to enact laws to, again, control Black people, at least in their voting.
A gap I cannot fill at the moment is the period after the successes of the Civil Rights Movement. Where were the analogous Black Codes of the 70s?