Array Display on LCD


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Posts
    6

    Angry Array Display on LCD

    I am having a problem showing my array values on my LCD module. Here is the code:

    MasterCode var byte[4]
    x var byte
    mastercode[0] = 5
    mastercode[1] = 4
    mastercode[2] = 3
    mastercode[3] = 2
    mastercode[4] = 1
    Pos var byte
    pos = 0


    lcdout $FE, 1, 2
    lcdout $FE, $C0, "Pausing for 5 sec"
    pause 5000
    Lcdout $FE, 1
    for x = 0 to 4
    lcdout $FE, $C0 + pos, Mastercode[x]
    pause 4000
    pos = pos + 1
    next x
    I paused the program so i could see exact what was going on...nothing. alot of cool symbols
    HELP PLEASE

  2. #2
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: Array Display on LCD

    Hi Nomad,

    I think what's happening is that you are displaying the ASCII character for the value contained in each element of the array.

    Try:
    lcdout $FE, $C0 + pos, DEC3 Mastercode[x]

    or:
    lcdout $FE, $C0 + pos, HEX2 Mastercode[x]

    Best Regards,
    Paul
    The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.

  3. #3
    Join Date
    Feb 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Talking Re: Array Display on LCD

    Thank you. I'll give it a try

  4. #4
    Join Date
    Feb 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Thumbs down Re: Array Display on LCD

    i have another question, how do i had dec values into a single array. My program is having a user press a button and have dec value stored into an array. Everything I try is not working. Here is the code
    Unlock:
    lcdout $FE, 1, "Please enter 5# Code"
    LOOP:
    if pos > 5 then
    goto Compare
    endif
    if portb.7 = 0 then
    pause 300
    lcdout $FE, 1, "Not Valid Number"
    goto unlock
    endif
    if portb.6 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 7
    pos = pos + 1
    x = x + 1
    endif
    if portb.5 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 4
    pos = pos + 1
    x = x + 1
    endif
    if portb.4 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 1
    pos = pos + 1
    x = x + 1
    endif
    if portb.3 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 0
    pos = pos + 1
    x = x + 1
    endif
    if portb.2 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 8
    pos = pos + 1
    x = x + 1
    endif
    if portb.1 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 5
    pos = pos + 1
    x = x + 1
    endif
    if portb.0 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 2
    pos = pos + 1
    x = x + 1
    endif
    if portc.0 = 0 then
    pause 300
    pause 300
    lcdout $FE, 1, "Not Valid Number"
    goto unlock
    endif
    if portc.1 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 9
    pos = pos + 1
    x = x + 1
    endif
    if portc.2 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 6
    pos = pos + 1
    x = x + 1
    endif
    if portc.3 = 0 then
    pause 300
    lcdout $FE, $C0 + pos, "*"
    UserCode[x] = 3
    pos = pos + 1
    x = x + 1
    endif
    goto loop

    Compare:

    PLEASE HELP

  5. #5
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Array Display on LCD

    Try using NCD & then Lookup to simplify your code.

    per the manual:
    4.17.12 NCD returns the priority encoded bit number 1-32 of a value. it is used to find the HIGHEST bit set in a vlaue. it returns 0 if no bit is set.

    b0 = NCD %010000100 'set b0 to 7



    so
    then use
    Code:
    If PortB <> $FF then 
    lookup PortB,[7,4,1,0,8,...],UserCode[x]
    ...
    endif

    hope that helps
    Last edited by ofuzzy1; - 6th March 2011 at 05:28.

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