As has been mentioned, move the while(1) to above the while(hwi>0) So; while(1) { while(hwi>0) { rest of code goes here } } You still have one problem to solve, that is once hwi reaches zero it will= =20 stay at zero, if you want this loop to be continuous you'll need to reload= =20 the variable.=20 Be careful of using the term constant for 'hwi', as misusing it could cause= =20 you or others confusion at some other time. Colin =20 -- cdb, colin@btech-online.co.uk on 13/03/2011 =20 Web presence: www.btech-online.co.uk =20 =20 Hosted by: www.justhost.com.au =20 =20 =20 =20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .