MY FIRST scrolling 8X8 LED


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Talking MY FIRST scrolling 8X8 LED

    HELLOi PICMASTERS Of The UNIVERSE
    Yep it's me again, back from North Eastern Utah for another battlestar galaxy imploding adventure in programming.
    The good news, I have the whole mutliplexing, DOT matrix stuff all figured out and working.
    The other good news, I have a basic scrolling program that does work.
    The other......news...I need help creating a lookup table that I can fetch ASCII values out of in an array type format...at least I think that is how I want to do this mission.

    Help me O-PIC-E-WAN's your my only help....(sorry it's still early in the morning for me).


    HERE IS MY WORKING CODE
    Code:
    '****************************************************************
    '*  Name    : MY FIRST SCROLLING LED.BAS                        *
    '*  Author  : Tyson Earl                                        *
    '*  Notice  : Copyright (c) 2008 Ty's Custom Electronics        *
    '*          : All Rights Reserved                               *
    '*  Date    : 8/13/2008                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    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
    
    COL1 VAR PORTB.0   'COLUMS ARE COMMON CATHODE, DO ALL THE SINKIN'
    COL2 VAR PORTB.1
    COL3 VAR PORTB.2
    COL4 VAR PORTB.3
    COL5 VAR PORTB.4
    COL6 VAR PORTB.5
    COL7 VAR PORTB.6
    COL8 VAR PORTB.7
    ROW1 VAR PORTC.0   'ROWS ARE THE INDIVIDUAL ANODES, DO ALL THE SOURCIN'
    ROW2 VAR PORTC.1
    ROW3 VAR PORTC.2
    ROW4 VAR PORTC.3
    ROW5 VAR PORTC.4
    ROW6 VAR PORTC.5
    ROW7 VAR PORTC.6
    ROW8 VAR PORTC.7
    
    HIGH SINK       'TURN OFF DOT MATRIX, NO SINKING CURRENT
    LOW  SOURCE     'NO SOURCED CURRENT
    
    MAIN:
    
    '********************************
    'HAPPY FACE APPEARS ON DOT MATRIX
    '********************************
    FOR z = 0 TO 200        'MULTIPLEX (SCAN) SCREEN 201 TIMES
    PAUSE 1
    PORTB   = %11111110
    SOURCEA = %00111100
    PORTC = SOURCEA
    PAUSE 1
    PORTB   = %11111101
    SOURCEB = %01101110
    PORTC = SOURCEB
    PAUSE 1
    PORTB   = %11111011
    SOURCEC = %11011011
    PORTC = SOURCEC
    PAUSE 1
    PORTB   = %11110111
    SOURCED = %10111111
    PORTC = SOURCED
    PAUSE 1
    PORTB   = %11101111
    SOURCEE = %10111111
    PORTC = SOURCEE
    PAUSE 1
    PORTB   = %11011111
    SOURCEF = %11011011
    PORTC = SOURCEF
    PAUSE 1
    PORTB   = %10111111
    SOURCEG = %01101110
    PORTC = SOURCEG
    PAUSE 1
    PORTB   = %01111111
    SOURCEH = %00111100
    PORTC = SOURCEH
    NEXT z
    
    '****************************************
    'SMILEY FACE SHIFTS QUICKLY ACROSS SCREEN
    '****************************************
    
    FOR STP = 0 TO 7           'SCROLL MR. SMILEY OFF SCREEN
        FOR S = 0 TO 20        '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
    HERE IS MY OTHER MAIN PROGRAM THAT DOES NOT WORK
    Code:
    'IN MAIN2 I WANT TO BE ABLE TO ENTER A "PARSED" STRING/SENTENCE TO THE SCREEN
    'THE IDEA BEING THAT YOU CAN ENTER IN "I DID IT!" AND THE 8X8 DOT MATRIX WILL
    'SCROLL ...I DID IT! FAST ACROSS SCREEN
    
    MAIN2:                           'NOT WORKING OBVIOUSLY
    FOR CHAR = "A","B","C","D","E")  'LOOKUP ASCII DECIMAL VALUE BY STEP/SHIFT????
        FOR STP = 0 TO 8             'SCROLL CHARACTER OFF PAGE NOT SURE HOW TO IMPLEMENT
            FOR S = 0 TO 20          'MULTIPLEX SCREEN PAUSING ~10ms EACH SCAN
    		  GoSub display	         'FETCH THE 8 ROWS 
            NEXT S 
        NEXT STP 
    NEXT CHAR		
    
    GOTO MAIN2
    
    'LETS ASSUME THAT THE DECIMAL VALUES FOR A~E WHERE ACTUALLY 0,1,2,3,4
    'IN THIS LOOKUP TABLE I WANT TO FETCH ALL 8 ROWS THAT MAKE UP ASCII CHARACTER
    'EVENTUALLY I WILL NEED TO HAVE FULL ASCII TABLE BUILT TO LOOKUP (IN TO)
    display:             'A   'B   'C   'D   'E  
            Lookup CHAR[0], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %11111110
            PAUSE 1
            Lookup CHAR[1], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %11111101
            PAUSE 1
            Lookup CHAR[2], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %11111011
            PAUSE 1
            Lookup CHAR[3], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %11111011
            PAUSE 1
            Lookup CHAR[4], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %11101111
            PAUSE 1
            Lookup CHAR[5], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %11011111
            PAUSE 1
            Lookup CHAR[6], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %10111111
            PAUSE 1
            Lookup CHAR[7], [$3F, $06, $5B, $4F, $66], PORTC
            PORTB = %01111111 
            PAUSE 1
    RETURN
    OBVIOUSLY you cannot count your way through a STING, and also probably obviously I have not idea what I am doing with the arrays either. I think by looking at my working program you will see where I am heading with MAIN2: and be able to offer some ideas that might get me back on track. I have tried to comment our all my ideas.

    Thanks for any help you can lend.
    May the force be with you!
    Padawan-78

  2. #2
    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.

  3. #3
    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

  4. #4
    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.

  5. #5
    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

  6. #6
    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!

  7. #7
    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

  8. #8
    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