PIC16F84A input

Translate This Thread From English to

Threaded View
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
damaged?

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.


Re: PIC16F84A input

Garrison,

  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.

DLC

: 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
: damaged?

: 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         dlc@frii.com                www.techtoystoday.com   *
* "Programming and Customizing the OOPic Microcontroller" Mcgraw-Hill 2003 *    
============================================================================

Re: PIC16F84A input



Or even an 18fxxx  as the prices are dropping.
Also there is the free microchip student version of the C18 compiler
if you use c.
<http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId 06&dDocName=en010014&part=SW006011>

18f's are faster and a lot have a good bit more flash and ram
for not much more.

16fxx code will run a lot of the time without changes for the 18f's,
just have to use the 18f fuse settings.

Think I'm going to find the time to put a short doc on how to change 16f
code to 18f
on my site. Probably need a few 18f examples.

In the middle of writing up how to get eclipse and gnu arm
installed and running on os x  as an addon to the
doc on new micros on getting eclipse and gnu arm running on windows.

Add it to this weekend's (long weekend) list
this doc , uni HPC fortran assignment , uni grid computing report,
uni group assignment on Terrahertz imaging.

Also don't forget to check the circuit cellar site
their Philips arm7 contest starts tomorrow.

Alex



Re: PIC16F84A input



schematic and routines at:
http://www.dontronics.com/psbpix/button.html

Don...


--
Don McKenzie
E-Mail Contact Page:       http://www.e-dotcom.com/ecp.php?un=Dontronics

RS-232 to VGA. Many resolutions http://www.dontronics.com/micro-vga.html
USB to RS232 Converter that works http://www.dontronics.com/usb_232.html



Site Timeline