Newbie problem :)


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2007
    Posts
    2

    Default Newbie problem :)

    Hi, I have some problems with my code for controlling some leds on my portB.

    I use MicroCode Studio/PBP 2.5a/16f877a


    TrisA=1
    TrisB=0

    If portA.0 = 1 then
    PortB = %11111111
    pause 2000
    else
    PortB = %00000000
    Endif



    When I press my key on portA.0 I wont to turn on all leds on portB, they should stay 2sec after I release it, and then turn off. But it wont work, is there some missing code here?

    Please help , I am Newbie

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    PortA.0 on the 16F877A (as well as many others) is an analog input by default and as such, will not work with 'digital commands'.
    You must change it to a digital input.
    This is also true of many PICs with built-in ADC's.

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    >>You must change it to a digital input. (from SkiMask)

    He is correct - to do this add

    Code:
    ADCON1 = 6
    before your TRIS commands and all should be well (see datasheet PORTA section for explanation)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Dec 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Thank you, it work's.

Similar Threads

  1. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  2. power problem (newbie here!)
    By clocks in forum General
    Replies: 10
    Last Post: - 2nd May 2009, 13:18
  3. SPI communication problem (newbie)
    By lm555cn in forum Serial
    Replies: 4
    Last Post: - 3rd March 2008, 15:33
  4. Newbie with LAB X1 timming problem
    By schlaray in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th November 2006, 00:30
  5. Replies: 2
    Last Post: - 13th September 2005, 18:23

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