itoa or wordtostring function?


Results 1 to 11 of 11

Threaded View

  1. #5
    Join Date
    Jan 2013
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: itoa or wordtostring function?

    Quote Originally Posted by Heckler View Post
    Could you give a couple of examples of what you mean?

    ie. show the unsigned 16 bit value and what the result should look like?
    Thanks for the reply. Here's the way I am doing it now, but it seems there should be a simpler way.

    Code:
    ' Program Code:
    PAUSE 1000 'Pauses 1 second to allow LCD to setup.
    start:
    ADCIN 0, left_pot 'Reads analog voltage on AN0, converts it to 10-bit digital
        'value, and stores it as left_pot.
    lpot = (left_pot*4) 'Multiplies left_pot times 4 to get voltage.
    lthousands = (lpot//10000)/1000 'Extracts thousands digit from 4 digit voltage.
    lhundreds = (lpot//1000)/100 'Extracts hundreds digit from 4 digit voltage.
    ltens = (lpot//100)/10 'Extracts tens digit from 4 digit voltage.
    lunits = (lpot//10) 'Extracts units digit from 4 digit voltage.
    ADCIN 1, right_pot 'Reads analog voltage on AN1, converts it to 10-bit digital
        'value and stores it as right_pot.
    rpot = (right_pot*4) 'Multiplies right_pot times 4 to get voltage.
    rthousands = (rpot//10000)/1000 'Extracts thousands digit from 4 digit voltage.
    rhundreds = (rpot//1000)/100 'Extracts hundreds digit from 4 digit voltage.
    rtens = (rpot//100)/10 'Extracts tens digit from 4 digit voltage.
    runits = (rpot//10) 'Extracts units digit from 4 digit voltage.
    LCDOUT $FE,1,"Left Pot  = ", DEC left_pot 'Clears LCD screen, displays
        '"Left Pot = " and the decimal value of left_pot.
    lcdout $FE,$C0,"Voltage   = ", #lthousands, ".", #lhundreds, #ltens, #lunits
        'Sends left pot voltage to LCD.
    LCDOUT $FE,$94,"Right Pot = ", DEC right_pot 'Sets LCD to beginning of
        'second line and displays "Right Pot = " and the decimal value of
        'right_pot.
    lcdout $FE,$D4,"Voltage   = ", #rthousands, ".", #rhundreds, #rtens, #runits
        'Sends right pot voltage to LCD.
    Here's a picture of the LCD with the above displayed.

    Name:  PIC16F88 TL431A ADC LCD Demo (lo res).jpg
Views: 1186
Size:  101.7 KB
    Last edited by tracecom; - 5th January 2014 at 04:58.

Similar Threads

  1. ARCSIN function
    By mjphillips1981 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th March 2009, 20:19
  2. Need help with write function
    By Christopher4187 in forum General
    Replies: 10
    Last Post: - 12th July 2006, 04:12
  3. COUNT Function
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th June 2006, 06:26
  4. How does serin function?
    By a_critchlow in forum Serial
    Replies: 3
    Last Post: - 7th February 2006, 08:10
  5. ATAN2(,) function
    By vk2tds in forum PBP Wish List
    Replies: 0
    Last Post: - 25th November 2005, 02:52

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