PDA

View Full Version : controlling portb output of 5bits in one line



tech
- 8th April 2007, 04:53
hi ,im new in pic controller.
im playing with pic16f84a.

i got a problem programing 5 bits of led from the portb output pins.

basically,i undestand by

HIGH 0
HIGH 1
HIGH 2
HIGH 3
HIGH 4

PAUSE 500

LOW 0
LOW 1
LOW 2
LOW 3
LOW 4

PAUSE 500


question is how can i just simply set the output high at any of the bits in just one line.doing the above could take up the memory lines.
any way i could shortened up the program.

example if i want to have it in the binary form
00001 'high on pin1
11010 'high on pin 1,3 and 4

thanks..

Jerson
- 8th April 2007, 05:22
example if i want to have it in the binary form
00001 'high on pin1
11010 'high on pin 1,3 and 4

Simple
PORTB = $01
PORTB = $1A

Happy Easter
Jerson

paul borgmeier
- 8th April 2007, 05:23
portb=31 ' or portb=%00011111
pause 500
portb=0 ' or portb=%00000000
pause 500




portb=1 ' or portb=%00000001

portb=26 ' or portb=%00011010

tech
- 8th April 2007, 05:59
its doesnt work ,bro...for both of u..

so any other way?

thanks

paul borgmeier
- 8th April 2007, 06:03
Are you running PicBasic Pro or BicBasic Compiler?

tech
- 8th April 2007, 06:06
pic basic pro compiler

paul borgmeier
- 8th April 2007, 06:11
ADD

TRISB=0 ' make all of PORTB = OUTPUTS
to the top of the examples posted by Jerson and me.

HIGH AND LOW make the pins an output for you - setting them with PORTB = 1 (for example), you have to make them outputs first since they default to inputs on power up.

tech
- 8th April 2007, 06:25
Thanks bro,

For the help and a quick reply..
This was a great forum to learn Pic with the user here.

Greetings from Singapore.

Happy Easter!!!

paul borgmeier
- 8th April 2007, 06:35
Thanks bro,You are welcome -

By the way who is bro? I hope and trust it is not me :eek:

http://www.urbandictionary.com/define.php?term=bro

Welcome to this forum

tech
- 8th April 2007, 06:41
haha...i mean the terms bro as in brother.

thanks alot.