PICMicro pin goes up and stays up

Ok, since many of us use PICs for our robots, I figure that here would be an appropriate place to ask for help, additionally, this should be an easy one
as I am clearly doing something wrong...
I've made a small program on my pic18f452 that basically watches for a port to go high or low (a button) and then sends the state of this port through a serial port. This application was working fine when the pic was on my development board (that has buttons), but it's acting weird now that I'm mounting it on a protoboard (those fiberboards full of holes). I've looked at the schematics of my dev board and all the switches do is to connect the pin to VCC, no resistors (do I need one?)
Let's say it is port RD1. I've set the TRISD.RD1 bit as input. This pin connected to one leg of a momentary on switch that connects directly to VCC (5V). When the pic was on the development board, pressing the button (I've taken care of debouncing) would drive RD1 high and releasing would let it go low. Now when I press the button it goes high allright, but then it stays high. If I try to probe it to see it on my oscope (even using a x10 probe), it goes low. Sometimes even if I touch the pin with my finger it will go low. Something related to capacitance right? My program, besides sending serial messages, it also drives PORTC.0 (TRISC.0=0) high or low accordingly to PORTD.1 state so I can double check it with a led. When it goes high after pressing the button, port RC0 goes high, but it oscillates close to 4V about 800mV.
I had similar problems in the past because I 1) had not connected VSS to my PIC 2) had not grounded (pulled down) unused pins
This time, VSS is connected to ground, any port that is not being used is connected to ground. I'm using an external crystal at 4MHz (HS mode) with two 15pF on each leg of the xtal (should I be using more? I doubt, serial communication, which is timing dependant is working fine). I was using a .1uF decoupling cap close to my VDD pin, I thought it was insufficient, then I've increased it to 1uF, same problem....
I have the impression that I'm forgetting something really simple....
Do you see what?
Thanks
Padu
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

be an

easy one

port
through a

I'm
looked
connect the

You need something to pull the pin down when the button isn't pressed. Or you could enable the built in pull-ups (if they are available on the port you are using) on the port and connect the switch from the port pin to ground (Vss). This would save you having to add resistors.

pin
to VCC

(I've
it go

high.
it
low.
Right. It's an input pin and has a very high input impedance. This means that a voltage can be applied to the pin and it will just basically sit there like a charge in a capacitor until something else acts on it. That's why you need something to tug it the other way when you aren't applying a voltage. To be accurate, the charge will eventually dissipate as it "leaks" into the gate, but it will take a little while.
The gate on a mosfet transistor behaves the same as an input pin on a PIC. You can touch your finger tip to Vcc and touch the gate and the mosfet will switch on. You can then touch Vss and then the gate causing it to turn off. You can also touch the gate with your index finger on one hand and touch your other index finger to Vss or Vcc (placing your whole body in series and more than enough current will still flow to switch the mosfet). You could probably chain together 10 or 12 people holding hands and have it still work fine.

check
goes
I'm not sure I understand you, but do you have current limiting resistor in series with the LED?

to my

Unused output pins can be left unconnected. Unused input pins should never be left floating. When I'm tinkering with PICs, I usually set all unused pins as output pins to avoid having to worry about them floating.

is
with
serial
a
It must be running then. Sounds like this is all ok.

insufficient, then

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
"Anthony Fremont"

I tried that yesterday, but thinking better now, maybe I did it on the wrong side... I've connected the pin to ground and one leg of the switch, and the other leg of the switch I've connected to VCC... obviously it became a short... I'll think better how to implement it properly.

Right on the bull's eye... the "monitoring led" stays high for a while and then it goes down by itself. Sometimes it takes less than one second, sometimes it takes more than 10 seconds, and sometimes it works perfectly.

Yes... I'm providing only 22mA to the led (220ohm resistor @ 5V). This led is there so I can "debug" what's happening inside the PIC.

Good to know... it is a major hassle to pull every pin low. If I set all unused ports as output, will it increase the current consumption of my device?
Cheers,
Padu
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
"Padu"

Today, with a clearer mind I saw what I did yesterday. I was trying to pull the pin down by connecting it to VCC..... lame....
Today it worked perfectly
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.