5x5 display 16f648a


Results 1 to 7 of 7

Threaded View

  1. #1

    Default 5x5 display 16f648a

    Saw a 5x5 display on you tube, daughter liked it so decided to make one.
    there was no code for it, so here it is in PBP.

    Code:
    '***************************************************
    '* Christmas stocking stuffer for Andi from dad
    '* 5x5 home made led display 
    '* pic 16F648A 
    '* December 2007
    '* by: Nomad (DSobelman(at)hotmail(dot)com)
    '****************************************************
    
    ' USE ALL CAPS for now, will add lower case or lower case conversion to caps later
    ' very limited character set for now (no time to add the rest right now)
    ' added space at beginning of data, project was skipping first character
    data " ANDREA ROCKS # MERRY CHRISTMAS MUNCHKIN #"
    
    @ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT
    '@ DEVICE pic16F648A, HS_OSC
    ' osc setting
    @ DEVICE pic16F648A, WDT_OFF   
    ' Watchdog Timer
    @ DEVICE pic16F648A, PWRT_ON
    ' Power-On Timer
    @ DEVICE pic16F648A, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic16F648A, BOD_OFF
    ' Brown-Out Detect
    @ DEVICE pic16F648A, LVP_OFF
    ' Low-Voltage Programming
    @ DEVICE pic16F648A, CPD_OFF
    ' code protect
    @ DEVICE pic16F648A, PROTECT_OFF
    'data protect
    
    defines:
    'define osc 20
    DEFINE OSC 4
    
            PORTB = 0 'turn off all 
            PORTA = 0
            TRISB = 0 'all output
            TRISA = 0
            CMCON = 7 'disable comparators
    
    Variables:
           
    row var byte    
    col var byte[8] 'was originally going to do scrolling on 8x8 but didn't have a board  
    x var word  'how many random patterns in random sub
    temp var word 'temp var for random HAS TO BE WORD (random doesn't work with byte)
    rowx var byte[5] 'store constant for each row 
    char var byte    ' index for lookup
    lettermark var BYTE 'pointer to eeprom address
    letter var byte 'temp for ascii convert
    clear
    
    constants:   'rows numbered 1-5, single each row out
    rowx[1] = 1
    rowx[2] = 2
    rowx[3] = 4
    rowx[4] = 8
    rowx[5] = 16
    
    start:
    GOSUB READ_STRING   'READ EEPROM DATA
    gosub get_char      'GET CHARACTER DATA
    gosub display_run   'DISPLAY CHARACTER
    gosub rand_disp     'SHOW RANDOM BLINKY STUFF (THEY LIKE BLINKY STUFF)
    goto start          'DO IT AGAIN WITH NEXT LETTER OVER AND OVER
               
    rand_disp:     'generate random noise on display
    for x=1 to 5  'dispplay "x" random patterns (full 5x5(8x8) patterns)
    random temp    'make random number
    pauseus 50
    PORTA = temp   'put out on porta (only uses low byte?) 
    random temp    'make row random number
    pauseus 50
    PORTB = temp   'put out on portb  
    pause 20       'how long to show pattern
    next x         'next pattern
    return
    
    display_run:        'show characters
    PORTA=0             'turn off all leds
    PORTB=0
    PAUSE 50             'forgot why this is here
    for temp = 1 to 1000 'how many full character loops (how long to display character)
    for row = 1 to 5      '5 loops, one for each row
    porta = 0             'turn rows off (kill ghosting)
    portb = col[row]      'put out row data for row(x)
    PAUSEUS 100           'settle
    porta = rowx[row]     'turn on row
    pauseus 100           'settle
    next row              'do again for each row to show full character
    next temp             'show character again (refresh/scan/whatever you wish to call it)
    return
    
    read_string:        'read data (message) from eprom
    lettermark = lettermark + 1  'go to next eeprom address
    IF LETTERMARK > 255 THEN     ' if at end  hmmm don't think I need this anymore
    LETTERMARK = 0                'was testing
    ELSE
    ENDIF
    READ LETTERMARK, LETTER      'read byte from eprom, assign to letter
    IF LETTER = $FF THEN         'check for end of message
    LETTERMARK = 0                'if end, reset eeprom pointer, make a space character
    LETTER = $20
    ELSE
    ENDIF
    PAUSEUS 500
    find_index: ' use lookdown to change ascii to a sequential index to keep lookup small
    LOOKDOWN LETTER,["- #ABCDEFGHIJKLMNOPQRSTUVWXYZ"],CHAR
    RETURN
    
    get_char:   ' get each of the row's data with index from converted ascii
    LOOKUP char,[$00,$00,$0A,$0E,$1E,$0E,$1C,$1F,$1E,$1E,$11,$0E,$07,$09,$08,$11,$11,$0E,$0E,$0E,$1E,$0E,$1F,$00,$11,$11,$11,$11,$1F],col[1]
    LOOKUP char,[$00,$00,$1B,$11,$09,$10,$0A,$10,$10,$10,$11,$04,$02,$0A,$08,$1B,$19,$11,$09,$11,$09,$10,$04,$0A,$11,$11,$0A,$11,$02],col[2]
    LOOKUP char,[$1F,$00,$04,$1F,$0E,$10,$0A,$1E,$1C,$16,$1F,$04,$02,$0C,$08,$15,$15,$11,$0E,$15,$0E,$0E,$04,$0A,$0A,$15,$04,$1F,$04],col[3]
    LOOKUP char,[$00,$00,$1B,$11,$09,$10,$0A,$10,$10,$12,$11,$04,$0A,$0A,$08,$11,$13,$11,$08,$12,$0A,$01,$04,$0A,$04,$1B,$0A,$04,$08],col[4]
    LOOKUP char,[$00,$00,$0A,$11,$1E,$0E,$1C,$1F,$10,$1E,$11,$0E,$0E,$09,$0E,$11,$11,$0E,$08,$0D,$09,$0E,$04,$0E,$00,$11,$11,$04,$1F],col[5]
    return
    end
    will have to extend the character set and add serial to change the message. but this was just for a quick toy, so I didn't do any of that.
    Attached Images Attached Images  

Similar Threads

  1. Hdsp 21xx display
    By Original in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th June 2012, 20:07
  2. Replies: 2
    Last Post: - 14th July 2008, 22:11
  3. DS1820 display with 7-seg 4 digits
    By chai98a in forum Code Examples
    Replies: 12
    Last Post: - 10th April 2008, 13:12
  4. Replies: 14
    Last Post: - 26th September 2007, 05:41
  5. graphics display
    By adlinsystems in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th June 2004, 12:53

Members who have read this thread : 0

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