Your variable bitsCount never gets reset to its original value.
Read this tutorial for a better way to read/parse input
Serial Input Basics - updated
Your variable bitsCount never gets reset to its original value.
Read this tutorial for a better way to read/parse input
Serial Input Basics - updated