Problem of combining code

Sorry for late reply!

"Is the serial port simply being used for debugging output?"

Yes, it is simply for debugging output.