MY FIRST scrolling 8X8 LED


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    http://www.picbasic.co.uk/forum/show...ght=copystring
    Simple macro to copy a string from the mainline of code into a byte array of STRING.
    Then you can dribble thru that byte array, pull out whatever you need...

    And if you do a search for 'printstr' (or in my case printstr2), you'll find another macro that is actually set up for either an LCD or the serial port but could be easily modified to drive 8x8 LEDs...which for all practical purposes are just like a graphic LCD as far as showing items.

    Take a look at them. If you've never messed with macro's, this is a perfect place to try them out and get to know them...
    Obviously, you can most likely do this without the macro's and just use lookup tables and such. I think you'll be much happier with the copystring/printstr/tables-in-flash concept.
    Last edited by skimask; - 14th August 2008 at 17:58.

  2. #2
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Skimask,
    I will do some looking into the macro coding,
    Looks like it does the job, can you show me where I would insert my string of characters?

    I would really like to use lookup tables for this project as I have a grasp on them.
    Right now I am just really stumped on how to use arrays with lookup tables to get a full 8x8 matrice of values to the screen one column at a time...???? then of coarse how to shift that entire matrice left or right while fetching the next array to feed into the screen.
    Padawan-78

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by earltyso View Post
    Skimask,
    I will do some looking into the macro coding,
    Looks like it does the job, can you show me where I would insert my string of characters?

    I would really like to use lookup tables for this project as I have a grasp on them.
    Right now I am just really stumped on how to use arrays with lookup tables to get a full 8x8 matrice of values to the screen one column at a time...???? then of coarse how to shift that entire matrice left or right while fetching the next array to feed into the screen.
    If the PIC you're using has internal eeprom, put the table there (the table is actually a matrix of what each character will look like when displayed on the LEDs, almost like what you've got in your first post). In fact, for testing, you could probably use the tables that are already in some of that code (5x7 font) and expand them later on. If the PIC doesn't have internal eeprom, you could still put the table into the code space (search 'making code space your playground').

    Shifting - tables - Rather than trying to figure out how to shift an entire column or whatever, I think you have to worry more about getting the thing to work in the first place just displaying single characters at will. Once that's finished, the code for shifting one column at a time should fall into place.

    Just as a for instance, say you want to display an O ( a big square O because it's easy) on an 8x8 LED. First byte (first column) is $ff, all 1's, 2nd-7th byte (columns) are %10000001 ($81), top and bottom LEDs on, last byte (column) is just like the first.
    When you display a character, you give it a code, such as using ASCII as I did (just not all of it). A big, capital O is ASCII value $4F (79 decimal).
    So now, say you've got a table already setup with all of the values plugged in. There's 127 ASCII characters (ok, not all of them displayable according to the ASCII standard, but you can use those non-displayable characters for 'special' characters).
    127 characters times 8 columns for each = 1,016 bytes total, call it 1K.
    You want to display character 'O', as in capital O. The ASCII value is $4F, so your loop would start at offset $4F times the number of bytes for each character (8), $4F x 8 = $278 (632 decimal), and run for 7 additional columns past that, for 8 columns total. After each read from memory for the byte values, you put that out to the LED matrix.

    If you get that working, it'll be a piece of cake to figure out how to do scrolling...
    Last edited by skimask; - 14th August 2008 at 20:11.

  4. #4
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default workin sorta

    I like the idea of storing the table to eeprom.
    Here is what I have come up with. So far I have built up A,B,C,D in my library and they are scrolling just fine by shifting 8 times to the left. Now what I want to do is have the letters scroll TOGETHER so that the letters merge into a sentence without 8 columns of dead space between letters.
    I will be trying to figure this out over the weekend. I still need to optimize my table but at its a start.


    Code:
    DEFINE OSC 12
    
    'ADCON1 = 4 'this sets ANO, AN1, AN3 ON
    ADCON1 = 7' ALL DIGITAL
    TRISB = 0
    TRISC = 0
    SINK   VAR PORTB 'ROWS
    SOURCE VAR PORTC 'COLUMNS
    x var byte
    y var byte
    z var byte
    A VAR BYTE
    B VAR BYTE
    S VAR BYTE
    STP VAR BYTE
    'CHAR var byte[8]
    
    SOURCEA VAR WORD
    SOURCEB VAR WORD
    SOURCEC VAR WORD
    SOURCED VAR WORD
    SOURCEE VAR WORD
    SOURCEF VAR WORD
    SOURCEG VAR WORD
    SOURCEH VAR WORD
    
    LETTERS VAR BYTE ' VARIABLE TO HOLD CHARACTERS IN F/N LOOP
    CHAR var byte[26]' ARRAY VARIABLE NAMED CHAR 26 ELEMENTS
    
    '* * * * * * LOAD ARRAY WITH STRING VALUE * * * * * * * * * * *
    
    CHAR[0]= "A"
    CHAR[1]= "B"
    CHAR[2]= "C"
    CHAR[3]= "D"
    CHAR[4]= "E"
    CHAR[5]= "F"
    CHAR[6]= "G"
    CHAR[7]= "H"
    CHAR[8]= "I"
    CHAR[9]= "J"
    CHAR[10]="K"
    CHAR[11]="L"
    CHAR[12]="M"
    CHAR[13]="N"
    CHAR[14]="O"
    CHAR[15]="P"
    CHAR[16]="Q"
    CHAR[17]="R"
    CHAR[18]="S"
    CHAR[19]="T"
    CHAR[20]="U"
    CHAR[21]="V"
    CHAR[22]="W"
    CHAR[23]="X"
    CHAR[24]="Y"
    CHAR[25]="Z"
    
    MAIN2:
    for x = 0 to 10
    lookup x, [0,1,2,3,3,3,2,2,1,1,0], LETTERS      'EQUIVALENT TO a,b,c,d,d,d,c,c,b,b,a
                                        'NOT WORKING OBVIOUSLY
    'FOR LETTERS = 0 TO 2               'LOOKUP ASCII CHARACTERS STORED IN MATRICE ARRAY ,A,B,C
        'FOR STP = 0 TO 1               'SCROLL CHARACTER OFF PAGE NOT SURE HOW TO IMPLEMENT
            'FOR S = 0 TO 1             'MULTIPLEX SCREEN PAUSING ~10ms EACH SCAN
    		  GoSub display	            'FETCH THE 8 ROWS 
            'NEXT S 
        'NEXT STP 
        
    NEXT X		
    GOTO MAIN2
    
    display:             'A   'B   'C   'D   'E  
            Lookup LETTERS, [$0, $0, $0, $0], SOURCEA
            PORTC = SOURCEA
            PORTB = %11111110
            PAUSE 1
            Lookup LETTERS, [%01000010, %01111110, %01111110,%01111110], SOURCEB
            PORTC = SOURCEB
            PORTB = %11111101
            PAUSE 1
            Lookup LETTERS, [%01000010, %01000010, %00000010,%01000010], SOURCEC
            PORTC = SOURCEC
            PORTB = %11111011
            PAUSE 1
            Lookup LETTERS, [%01111110,%01000010 , %00000010,%01000010], SOURCED
            PORTC = SOURCED
            PORTB = %11110111
            PAUSE 1
            Lookup LETTERS, [%01000010, %01000110, %00100010,%01100010], SOURCEE
            PORTC = SOURCEE
            PORTB = %11101111
            PAUSE 1                     
            Lookup LETTERS, [%00111100, %00111010, %00111100,%01011100], SOURCEF
            PORTC = SOURCEF
            PORTB = %11011111
            PAUSE 1
            Lookup LETTERS, [$0, %00000010, $0,%01000000], SOURCEG
            PORTC = SOURCEG
            PORTB = %10111111
            PAUSE 1
            Lookup LETTERS, [$0, %00000010, $0,%01000000], SOURCEH
            PORTC = SOURCEH
            PORTB = %01111111 
            PAUSE 1
            
    FOR STP = 0 TO 7           'SCROLL MR. SMILEY OFF SCREEN
        FOR S = 0 TO 15        'SCAN SCREEN 21 TIMES (FAST) BETWEEN SCROLLING
            PAUSE 1
            PORTB = %11111110
            PORTC = SOURCEA >>STP
            PAUSE 1
            PORTB = %11111101
            PORTC = SOURCEB >>STP
            PAUSE 1
            PORTB = %11111011
            PORTC = SOURCEC >>STP
            PAUSE 1
            PORTB = %11110111
            PORTC = SOURCED >>STP
            PAUSE 1
            PORTB = %11101111
            PORTC = SOURCEE >>STP
            PAUSE 1
            PORTB = %11011111
            PORTC = SOURCEF >>STP
            PAUSE 1
            PORTB = %10111111
            PORTC = SOURCEG >>STP
            PAUSE 1
            PORTB = %01111111
            PORTC = SOURCEH >>STP
        NEXT S
    NEXT STP
    'GOTO MAIN
            
    RETURN
    Padawan-78

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Instead of this:

    Code:
    '* * * * * * LOAD ARRAY WITH STRING VALUE * * * * * * * * * * *
    CHAR[0]= "A"
    CHAR[1]= "B"
    CHAR[2]= "C"
    CHAR[3]= "D"
    CHAR[4]= "E"
    CHAR[5]= "F"
    CHAR[6]= "G"
    CHAR[7]= "H"
    CHAR[8]= "I"
    CHAR[9]= "J"
    CHAR[10]="K"
    CHAR[11]="L"
    CHAR[12]="M"
    CHAR[13]="N"
    CHAR[14]="O"
    CHAR[15]="P"
    CHAR[16]="Q"
    CHAR[17]="R"
    CHAR[18]="S"
    CHAR[19]="T"
    CHAR[20]="U"
    CHAR[21]="V"
    CHAR[22]="W"
    CHAR[23]="X"
    CHAR[24]="Y"
    CHAR[25]="Z"
    Try this:
    Code:
    For temp = "A" to "Z" : CHAR[ temp - "A" ] = temp : Next temp
    Easier to type, uses less memory, and so on...

    Another idea for you...

    Put the complete message into an array of bytes, the whole message, columns and all, not just the ASCII representation of each character (i.e. each character will use up 8 bytes in the array).
    Then, when displaying the message, (is the matrix actually 8x8? or are there really more 8x8 chunks involved?), shift the array by one column, pause, redisplay it...
    Last edited by skimask; - 15th August 2008 at 16:24. Reason: screwed up the code! it's fixed now!

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Instead of this:

    Code:
    '* * * * * * LOAD ARRAY WITH STRING VALUE * * * * * * * * * * *
    CHAR[0]= "A"
    CHAR[1]= "B"
    CHAR[2]= "C"
    CHAR[3]= "D"
    CHAR[4]= "E"
    CHAR[5]= "F"
    CHAR[6]= "G"
    CHAR[7]= "H"
    CHAR[8]= "I"
    CHAR[9]= "J"
    CHAR[10]="K"
    CHAR[11]="L"
    CHAR[12]="M"
    CHAR[13]="N"
    CHAR[14]="O"
    CHAR[15]="P"
    CHAR[16]="Q"
    CHAR[17]="R"
    CHAR[18]="S"
    CHAR[19]="T"
    CHAR[20]="U"
    CHAR[21]="V"
    CHAR[22]="W"
    CHAR[23]="X"
    CHAR[24]="Y"
    CHAR[25]="Z"
    Try this:
    Code:
    For temp = "A" to "Z" : CHAR[ temp ] = temp : Next temp
    Easier to type, uses less memory, and so on...

    Another idea for you...

    Put the complete message into an array of bytes, the whole message, columns and all, not just the ASCII representation of each character (i.e. each character will use up 8 bytes in the array).
    Then, when displaying the message, (is the matrix actually 8x8? or are there really more 8x8 chunks involved?), shift the array by one column, pause, redisplay it...
    Ski,


    About the array loop and indexing it;

    When Temp = "A", how will "CHAR[ temp ] = temp" work?

    Where will "A" go? CHAR[65] ?


    What about CHAR[Temp-65] = Temp ?


    ---------------------

    Note: I just realized that my edit updated after Ski posted!
    Last edited by sayzer; - 15th August 2008 at 16:26.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Ski,

    About the array loop and indexing it;

    When Temp = "A", how will "CHAR[ temp ] = temp" work?

    Where will "A" go?
    CHAR[65] ?

    Nothing personal, just want to know
    DOH!!!
    Char[ temp - "A" ]
    That should be a bit better, ya think?

    Note: I just saw that Sayzer had edited after I had posted
    Last edited by skimask; - 15th August 2008 at 22:45.

Similar Threads

  1. 8x8 LED Matrix - Car / Boat Game (16F872)
    By wellyboot in forum Code Examples
    Replies: 4
    Last Post: - 13th February 2014, 21:28
  2. 8x8 Scrolling LED display (Simple example)
    By wellyboot in forum Code Examples
    Replies: 68
    Last Post: - 11th July 2013, 05:03
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  4. 5x7 LED Matrix Scrolling Display
    By roycarlson in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 4th August 2008, 23:50
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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