Shop OBEX P1 Docs P2 Docs Learn Events
Lookup Table Help — Parallax Forums

Lookup Table Help

GorillaGorilla Posts: 16
edited 2012-01-06 08:06 in BASIC Stamp
I have 7 segment displays multiplexed common anode displays the 7 segs are connected to a 7447 bcd decoder. I wrote a look up table and the only way I can get it to work correctly is by typing the binary equivalent of the numbers i.e. %0111 for seven this takes time, what I really want to do is just type a 7 and then output the binary equiv OUTA.


' {$STAMP BS2p}
' {$PBASIC 2.5}


'====Main Program===
duration CON 500
charNum VAR Nib

DIRA=%11111111

DO

FOR charNum = 9 TO 0
LOOKUP charNum, [1,2,3,4,5,6,7,8,9],DIRA
PAUSE duration
NEXT

LOOP

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-01-06 08:06
    duration CON 500
    charNum VAR Nib
    segdata  VAR Nib
    
    DIRA=%11111111
    
    
    DO
    
    FOR charNum = 0 TO 9
    LOOKUP charNum, [0,1,2,3,4,5,6,7,8,9], segdata
    OUTA = segdata
    PAUSE duration
    NEXT
    
    LOOP
    

    You could just use OUTA=charNum, but I figured you needed/wanted help with LOOKUP
Sign In or Register to comment.