convert the numbers to word


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default convert the numbers to word

    Code:
    getword: 
        for x = 0 to 3
        Gosub getkey                ' Get a key from the keypad  
        lcdout I,Line2 + x,#key     ' Display ASCII key number
        next
        return
    I have a keypad and show the key on LCD if a button pressed.
    Like this : 2438
    How i can convert the numbers 2438 as a variable(word 2.438)

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    Code:
    getword: 
        for x = 0 to 3
        Gosub getkey                ' Get a key from the keypad  
        lcdout I,Line2 + x,#key     ' Display ASCII key number
        next
        return
    I have a keypad and show the key on LCD if a button pressed.
    Like this : 2438
    How i can convert the numbers 2438 as a variable(word 2.438)
    http://www.picbasic.co.uk/forum/showthread.php?t=6050
    Posts #3 and #5

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I don't want this
    If i press the button 2 i take 2 , after i press the button 4 and take 4 ,etc
    3 and 8
    How to take a word with this number : 2 and 4 and 3 and 8
    like this: value = 2438
    Last edited by savnik; - 11th April 2007 at 20:54.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I don't this
    If i press the button 2 i take 2 , after i press the button 4 and take 4 ,etc
    3 and 8
    How to take a word with this number : 2 and 4 and 3 and 8
    like this: value = 2438
    I guess there's a bit of a language barrier going on here. I don't really get what you're trying to say...

  5. #5
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile My guess

    Hi savnik,

    See if I read you correctly.
    You want the user to be able to press a series of buttons, on your keypad. You would like the PIC to take this series of separate button values and “string them together” (“concatenate” them). Then use them as a PIC WORD variable in your program.

    You are able to read the individual button presses, but are having trouble putting them together to make the variable.

    Is that close?

    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Default

    Perhaps somthing like this will do what you want.
    Code:
    getword:
        value = 0 
        for x = 0 to 3
            Gosub getkey                  ' Get a key from the keypad  
            lcdout I,Line2 + x,#key     ' Display ASCII key number
            SELECT CASE x               
               CASE 0 
                  value = value + (key * 1000)
               CASE 1 
                  value = value + (key * 100)
               CASE 2 
                  value = value + (key * 10)
               CASE 3 
                  value = value + key
            END SELECT
        next
        return

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    Hi savnik,
    You want the user to be able to press a series of buttons, on your keypad. You would like the PIC to take this series of separate button values and “string them together” (“concatenate” them). Then use them as a PIC WORD variable in your program.
    You are able to read the individual button presses, but are having trouble putting them together to make the variable.
    Is that close?
    -Adam-
    Ok, well that makes a bit more sense to me...

    getword:
    for x = 0 to 3
    Gosub getkey ' Get a key from the keypad
    keyin(x) = key 'save the individual keypresses
    lcdout I,Line2 + x,#key ' Display ASCII key number
    next
    outval = ( keyin(0) * 1000 ) + ( keyin(1) * 100 ) + ( keyin(2) * 10 ) + keyin(3)
    return

  8. #8
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    sorry but my english is not good
    when press the button 2 on keyboard the LCD show 2 on first position and after when press the button 4 on keyboard the LCD show 4 on second position etc.
    I want the number 2,4,3,8 to be a variable (dec 2.348)

  9. #9
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    Hi savnik,

    See if I read you correctly.
    You want the user to be able to press a series of buttons, on your keypad. You would like the PIC to take this series of separate button values and “string them together” (“concatenate” them). Then use them as a PIC WORD variable in your program.

    You are able to read the individual button presses, but are having trouble putting them together to make the variable.

    Is that close?

    -Adam-
    yes , i want it

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    sorry but my english is not good
    when press the button 2 on keyboard the LCD show 2 on first position and after when press the button 4 on keyboard the LCD show 4 on second position etc.
    I want the number 2,4,3,8 to be a variable (dec 2.348)
    You want the variable in memory (whether it be a byte or a word) to be:
    x = 2.348 ?

  11. #11
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ingvar View Post
    Perhaps somthing like this will do what you want.
    Code:
    getword:
        value = 0 
        for x = 0 to 3
            Gosub getkey                  ' Get a key from the keypad  
            lcdout I,Line2 + x,#key     ' Display ASCII key number
            SELECT CASE x               
               CASE 0 
                  value = value + (key * 1000)
               CASE 1 
                  value = value + (key * 100)
               CASE 2 
                  value = value + (key * 10)
               CASE 3 
                  value = value + key
            END SELECT
        next
        return
    Thank you
    I wanted something like this
    Last edited by savnik; - 11th April 2007 at 22:10.

  12. #12
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Smile

    Maybe this is more effectiv:

    Code:
    getword:
        value = 0 
        for x = 0 to 3
            Gosub getkey                  ' Get a key from the keypad  
            lcdout I,Line2 + x,#key     ' Display ASCII key number
            value=Value*10+key
        next
        return
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Quote Originally Posted by BigWumpus View Post
    Maybe this is more effectiv:

    Code:
    getword:
        value = 0 
        for x = 0 to 3
            Gosub getkey                  ' Get a key from the keypad  
            lcdout I,Line2 + x,#key     ' Display ASCII key number
            value=Value*10+key
        next
        return
    OH...that is pretty slick...

  14. #14
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BigWumpus View Post
    Maybe this is more effectiv:

    Code:
    getword:
        value = 0 
        for x = 0 to 3
            Gosub getkey                  ' Get a key from the keypad  
            lcdout I,Line2 + x,#key     ' Display ASCII key number
            value=Value*10+key
        next
        return
    Yes , is more effectiv
    Thank you

Similar Threads

  1. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  2. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

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