Hi dw_picbasic,

I'm an electrician and when I need a lamp to light on, I turn on (a kind of "1" level) the button that will provide energy to the lamp.

In electronic, it is different. As I learned over time, a good practice is to use "inverted-logic" for digital inputs.

I see, you pull-down your input pin so you wait for a high level (or "1" or "active high") to trigger an event. I might suggest you to "invert" your way of thinking and trigger your event(s) when the button goes to a "low" level (or "0" or "active low").

Waiting for a "low level" means that you need to keep the input always "high" like in this shema.

Name:  000569.png
Views: 285
Size:  37.6 KB

Your PIC has alread built-in "weak pull-ups" (find this in your datasheet) like R1 so you don't need to add anything to your button. Use them in place of your external resistor(s)

This way of doing has some advantages and one of them is a good protection against noise.

Name:  000562.png
Views: 331
Size:  16.2 KB