The basic idea is to read the port periodically (called polling). Your program will usually have a main loop that continues to execute constantly. Somewhere in the main loop, you need to test your port for the desired input. Here is some untested code: portb equ 0x06 mirrorb equ 0x0C ;; temporary register to store contents of portB ;; Main Loop MainLoop clrwdt ;; do this once at the beginning of your main loop ;; Poll Port movf portb, w movwf mirrorb btfss mirrorb, 1 ;; read, for example, pin 1 active low on port B goto process goto someothertask process someothertask: < do some other tasks> goto MainLoop If you can get this idea to work, that's great. But for a real project, this is too simple. You should plan to get more sophisticated by debouncing your input. Read the input, if it is active, set a flag. Read the input later, and if it is still active, then execute the process triggered by the input. Start by getting your input to light an LED and move up from there. You will sometimes need to disable the input after it has been processed, to prevent a key press from executing the process over and over. In this case, you ignore the flag until you have passed so many mainloops. You will need to tune this value to work with your application. This is a very simple and straightforward approach. I usually use timer interrupts to process keypresses, but I would recommend you grapple interrupts at a later time. BTW, where are you located? -- Lawrence Lile Quah Yow Chun Sent by: pic microcontroller discussion list 10/09/02 11:48 PM Please respond to pic microcontroller discussion list To: PICLIST@MITVMA.MIT.EDU cc: Subject: Reading Pulse Input I am new to PIC, I am trying to write code to test whether an input pulse exist. Any samples programs in machine language code to test exist of input pulse. I am using PIC16F84. James -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads