For some that uses a USB to Serial converter, they are required to test the converter is working properly. Some have been reported not working. The converter can be test by connecting pin 2 and pn 3 together. This allows the data sent from Hyperterminal to loop back to the terminal. After this is done, the above codes can be used to make sure the serial is function properly.
Figure 1: Connecting pin 2 and pin 3 of seriall
Figure 2: Terminal showing the loop back
These test allows you to save time by debugging the necessary erroneous parts in your development.