left shift help Plz


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2016
    Posts
    4

    Default left shift help Plz

    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:
    Code:
    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

  2. #2
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: left shift help Plz

    Try
    PORTD = (PORTD << 1) + 1
    Phil

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: left shift help Plz

    there are many ways to accomplish this...

    one that I can think of is to use the LOOKUP statement...
    Code:
    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
    Last edited by Heckler; - 27th March 2016 at 15:26.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. turning Motor left & right using pic Help plz
    By janosandi in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th March 2016, 22:47
  2. Another way to left shift a 32 bit data?
    By Ioannis in forum General
    Replies: 21
    Last Post: - 12th December 2015, 17:49
  3. Shift Right, Left
    By tazntex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th July 2010, 15:28
  4. Replies: 2
    Last Post: - 7th March 2008, 02:16
  5. out in left field
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th March 2007, 16:19

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