
Originally Posted by
tazntex
Good Morning to All,
I was wondering if I declared a variable such as, train var byte, then I had another variable, car var byte, in which if there was a car car.0[0] =1 and I wanted to send to portb the bits in train 1,2,3,4,5,6,7 to make portb pins 1-7 high or low depending on how the bits are set in train but I wanted portb.0 to be high or low depending on the value of car. In this way I could have portb pin 0 showing a car is there and portb pins 1-7 providing high or low outputs to control other things. How could I do this together? The Pic I am using is a 16f628a.
If I understand you correctly, you want PORTB to be equal to bit0 from CAR and bits1-7 from TRAIN?
Code:
SETB VAR BYTE
' In your program somewhere
SETB = TRAIN
SETB.0 = CAR.0 ' redefine bit0 to match that of Car's bit 0
PORTB = SETB ' set PORTB equal to the desired values of bit 0 from Car and bits 1-7 from train
This could also be easily done with boolean (bitwise) algebra if speed or program size is of importantance.
Last edited by paul borgmeier; - 31st January 2008 at 18:29.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Bookmarks