I am trying to build a program that uses the count function on a pin of a 16f877A pic. The program must count to a number around 150,000 and with the 16 bit limit I know this is impossible. I have the program counting for one second before looping and adding the counts to CountTotal. In the end I would like to make it a number between 0 and 15,000. I am just having trouble wrapping my brain around an easy way of doing this. I have thought about taking the counts and dividing it by 10 and adding it to a countsTotal and taking the remainder and making it the starting number for counts on the next loop. If someone can show me a more efficient way of doing the math it would be much appreciated.