If you really wanted to learn you would start off with a simple project, like learning how to make a LED blink. Being you came here asking for someone to make code that you did not right and make it work for you tells us that you do not want to learn.

Do you have a copy of PBP? If you do and as you stated you did not buy it, that is another problem.