Now is the time to brush off your analytical skills, that alone will
answer your questions. But, until then...
The best way to implement this is to use a pull up resistor from the
IO line to 5V. 10K is a good value. Now you connect the common of
the switch to the IO line and the NO (normally open) side of the switch
to the ground. The pin will read '1' until the button is pressed, then
it will read '0'. Since you appear to be a newcomer to the art I
strongly suggest that you put a buffer resistor between the IO line of
the PIC to the switch. In this way if you goof, make the IO line an
output and them short that to ground via the switch you won't let the
magic smoke out of the PIC.
Now on to the other bit, why on Earth are you using a 16F84A? That
is last century's news. You should be using something like a 16F628A
or 16F88, items with built in UARTs, more interrupt sources and way
better hardware peripherals - Also, if you check the part costs, these
newer parts are cheaper.
: I am building a small wheeled robot for a project and I am having
: trouble with the input on the PIC16F84A microcontroller. I want to make
: some basic pushbutton/switch inputs on Port B. How do I wire this? Do I
: run a wire from the positive power rail to the switch and then to the
: input, or from the input to the switch to the negative power rail?
: Also, will I need a resistor in there to keep the circuit from getting
: Also, how does the input appear programming-wise? Does the input pin
: simply return a 1 or a 0? I'd greatly appreciate any help on the matter.
* Dennis Clark firstname.lastname@example.org www.techtoystoday.com *
Click to see the full signature.