PDA

View Full Version : left shift help Plz



janosandi
- 26th March 2016, 21:15
hello Guys
I have 1 7segment display which i want the segments to lit one bye one like a running wheel
this is the code i've tried:


segRoutine:
low PORTC.5
PORTD = $FE '11111110
Pause 1000
PORTD = PORTD << 1 '11111100
pause 1000
PORTD = PORTD << 1 '11111000
pause 1000
PORTD = PORTD << 1 '11110000
pause 1000
PORTD = PORTD << 1 '11100000
pause 1000
PORTD = PORTD << 1 '11000000
pause 1000
goto segRoutine



it works but the segments lit like A > A+B > A+B+C > A+B+C+D >.......
i want it to run one by one A > B > C > D > E > F.
any idea?


thx Guys
John

Sherbrook
- 27th March 2016, 15:04
Try
PORTD = (PORTD << 1) + 1
Phil

Heckler
- 27th March 2016, 15:16
there are many ways to accomplish this...

one that I can think of is to use the LOOKUP statement...

NextSeg:
FOR x = 0 to 7
LOOKUP x,[254,253,251,247,239,223,191,127],display
GOSUB segRoutine
PAUSE 1000
GOTO NextSeg

In the lookup statement above you can choose to also represent the lookup table in $Hex or %Binary
like this... %01111111,%10111111,%11011111 etc.
or $FE,$FD,$FB, etc