Problem with peek in portB


Closed Thread
Results 1 to 2 of 2
  1. #1
    hawk72501's Avatar
    hawk72501 Guest

    Angry Problem with peek in portB

    Hi guys. I have connected 8 wires with 5 volts at the 8 pins of portB .PortC is ok.It makes only a serial communication and i have tested it.

    I made that program in order to understand when the wires are 0V or 5V and which of these are 0V or 5V .For example if the RB7 takes 1 (+5 volts)and the others 0 (0volts) i want to take the number 127.

    INCLUDE "modedefs.bas"

    TRISB=%11111111 (i make them all inputs)
    TRISC=%00000010
    B0 VAR BYTE



    loop:
    Peek PORTB,B0

    SerOut2 PORTC.0,84,["I took:",DEC B0,13,10]

    GoTo loop

    But it doesn't work this way.fOR EXAMPLE when i had 5 volts only at RB0 (and the others had no voltage) i took number 5 and not 1 as i expected.

    hAS anybody any idea how to do it? Thanks

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It's not revelant to your problem but ss you probably have PBP, you don't need to use PEEK or POKE. just use
    Code:
    MyVar var byte
    
    MyVar=PORTB
    BUT
    fOR EXAMPLE when i had 5 volts only at RB0 (and the others had no voltage)
    By NO VOLTAGE do you mean that those pin are left floating??? IF so pull-down resistor will help.

    A PIC can't read nothing... it's 1 or 0. So you must set your pin to VDD or VSS with jumper or with resistor. Common val;ue for pull-down/pull-up 10K or less. AND, personally, when i use to set a pin to VDD or VSS i add a resistor in serie for current limiting.
    Last edited by mister_e; - 27th August 2005 at 12:04.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. Problem accessing keypad on PortB (LabX1, PIC 18F452)
    By scorpion4377 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th January 2009, 03:52
  3. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

Members who have read this thread : 1

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