Help with button and 16F877a


Closed Thread
Results 1 to 5 of 5
  1. #1

    Default Help with button and 16F877a

    Hi all! As you can see I am a new member here and even greener in the world of MCUs. So far I have been able to successfully accomplish small feets in programming such as interfacing a serial LCD, blinking an LED, etc. However I am having trouble getting a button to work. What I am trying to do is get a button input on PortA.2 to turn on an LED connected to PortA.1. I can turn the LED on and off I just cant get the button input to work. Not sure if I have the pin configured incorrectly but any help would be greatly appreciated!!!

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Since you're using PORTA (Analog pins) as digital ...
    I might suggest ...

    ALLDIGITAL.pbp
    http://www.picbasic.co.uk/forum/showthread.php?t=11100
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks for the link.
    Is there not just a short command that I can place into the code that will change all of PortA pins to digital input? I have been able to get the button to work on PortB so I am sure my code is right, is just doesnt work on PortA.
    Sorry for the newb questions!

    Would this work?
    Code:
    CMCON = 7
    ADCON1 = 7
    Last edited by gtrplaya101; - 13th October 2009 at 21:28.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gtrplaya101 View Post
    Thanks for the link.
    Is there not just a short command that I can place into the code that will change all of PortA pins to digital input?
    That's what AllDigital does ...
    Code:
    INCLUDE "ALLDIGITAL.pbp"
    Would this work?
    Code:
    CMCON = 7
    ADCON1 = 7
    Yes, that will work on a 16F877A.
    And is exactly what AllDigital would do.

    But when you go to use a different chip, those registers will probably not work anymore and you'll have to search the datasheets to see which ones are needed for that chip.

    AllDigital will still work no matter which chip you are using.
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    thanks that did the trick!

Similar Threads

  1. what's wrong 16F877A simple code?
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th October 2009, 01:11
  2. 16F877 vs. 16F877A
    By DavyJones in forum General
    Replies: 12
    Last Post: - 11th April 2009, 18:22
  3. Help Pbasic to PBP
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd March 2009, 18:35
  4. button pullup/down resistor?
    By davewanna in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th June 2008, 05:13
  5. Reaction timer using 16f877a and pbp
    By sphinxifm in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th July 2007, 14:28

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts