Searching \ for 'Read a value on PORTB' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'Read a value on PORTB'.

Truncated match.
PICList Thread
'Read a value on PORTB'
1999\07\31@112905 by Leonardo Schunk

picon face
I need a Help.
Hi, i am a begginer on mcus, and I started on 16f84
has 3 weeks, i am training the possibilities of this
microcontroler and i need help with a problem.
I am trying to do something very simple : press a
button on RB3 and turn on a led on RB4.
But i don't know how to do that !!
I've bought a book about pic (the only in portuguese
yet, but this book have wrong examples and informatons
- it's a crap book !!!)
I need to know how i read the value of RB3 ( i am
using the pull up resistor - so i get the low level
when i press the button) and how i work with this.
Thanks a lot !!!!

Leonardo Schunk
Do You Yahoo!?
Free instant messaging and more at

1999\07\31@122219 by Dan Creagan

This ought to bring out a bunch of answers. Here's one:

portb    equ          0x06
           org            000
           movlw       b'111101111'
           tris             portb     ;portb set to inputs
except for port 4
           bcf             portb,4  ;clear port b
s1        btfss         portb,3  ;bit 3 high?
           goto          s1          ;no, wait for it to go
s2        btfsc         portb,3  ;bit 3 low - wait until
button released
           goto          s2          ;not released
           bsf            portb,4   ; set port b
loop     goto         loop
{Original Message removed}

'Read a value on PORTB'
1999\08\01@092413 by paulb
Perhaps this simple "echo" routine may be more useful to start with,
apologies to Dan Creagan:

portb   equ     0x06
       org     0
       movlw   b'111101111'
       tris    portb   ;portb set to inputs except for port 4

loop    btfss   portb,3 ; bit 3 high?
       bcf     portb,4 ; if not, clear port b,4
       btfsc   portb,3 ; bit 3 low?
       bsf     portb,4 ; if not, set port b,4
       goto    loop

       Paul B.

1999\08\02@154812 by Dmitry Kiryashov

Hi Leonardo. Couple of academical examples more...

WBR Dmitry.

> portb   equ     0x06
> ;
>         org     0
> ;

>         movlw   b'111101111'
>         tris    portb   ;portb set to inputs except for port 4

       rlf     PORTB,W         ;read from PORTB and shift it to W
       movwf   PORTB           ;pit it back to PORTB
       goto    Loop

       movlw   0               ;if PORTB.3=0 load W.4=0
       btfsc   PORTB,3
       movlw   0x10            ;if PORTB.3=1 load W.4=1
       movwf   PORTB
       goto    Loop

> loop    btfss   portb,3 ; bit 3 high?
>         bcf     portb,4 ; if not, clear port b,4
>         btfsc   portb,3 ; bit 3 low?
>         bsf     portb,4 ; if not, set port b,4
>         goto    loop

1999\08\02@165947 by Darren Logan

picon face
Ok great, but why not do it in one line of code wth a higher level language.

Take Pic BASIC for example.
Here's how to read a port:

ByteVariable = PortB

That's it.


More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...