>> > Can anybody be kind to help me to do a code snippet > who shall count pulses from a mechanical switch in to a PIC 16F84. > It will be three pulses to count before the program runs > again. The time between the pulses is about 15 ms. A couple years ago a question like this would've gotten several responses... There are several ways to go about this, so I'll suggest one and let others interject. First, it's probably obvious that to count pulses you need to look for edges. And when an edge is found increment a pulse counter if it was a low to high transition. Here's some (inefficient) psuedo code: << Dont forget to debounce the mechanical switches, or you will count many edges for every real switch event. ***************************************************************** Olin Lathrop, embedded systems consultant in Devens Massachusetts (978) 772-3129, olin@cognivis.com, http://www.cognivis.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:","[SX]:","[AVR]:" =uP ONLY! "[EE]:","[OT]:" =Other "[BUY]:","[AD]:" =Ads