Black Codes were intended to limit the political and social freedoms of newly freed blacks in the South.
After the Civil War, the era of Reconstruction saw a tremendous growth in terms of the rights guaranteed to African-Americans. The Reconstruction amendments (amendments 13, 14, and 15) helped to grant citizenship, outlaw slavery, and give African American males the right to vote.
At the end of the Reconstruction era, the South wanted to limit these freedoms. Southerners were fearful of the new rights gained by these individuals. This is why black codes called for separate facilities and restrictions on the voting rights of African American citizens.