A/D display result on LCD


Results 1 to 16 of 16

Threaded View

  1. #1
    winsthon's Avatar
    winsthon Guest

    Default A/D display result on LCD

    Hi Im new to BASIC. I have a problem about PIC16F877 A/D...I want to display the digital output of the analog input signal and convert it as HEX value and display it on the LCD.

    I have a code using BASIC but I dont know how to display the HEX equivalent so instead I use # to display the decimal value. can anyone help me how to do this convert the decimal value into its HEX equivalent...Here's my code...

    Define ADC_CLOCK = 3 'default value is 3
    Define ADC_SAMPLEUS = 10 'default value is 20
    Define LCD_BITS = 8 'allowed values are 4 and 8 - the number of data interface lines
    Define LCD_DREG = PORTB
    Define LCD_DBIT = 0 '0 or 4 for 4-bit interface, ignored for 8-bit interface
    Define LCD_RSREG = PORTD
    Define LCD_RSBIT = 1
    Define LCD_EREG = PORTD
    Define LCD_EBIT = 3
    Define LCD_RWREG = PORTD 'set to 0 if not used, 0 is default
    Define LCD_RWBIT = 2 'set to 0 if not used, 0 is default

    Dim an0 As Word
    Dim an1 As Word
    Dim an2 As Word

    TRISA = 0xff 'set all PORTA pins as inputs
    ADCON1 = 0 'set all PORTA pins as analog inputs
    Lcdinit 'initialize LCD module; cursor is off

    loop:
    Adcin 0, an0
    Adcin 1, an1
    Adcin 2, an2
    Lcdcmdout LcdClear 'clear LCD display
    Lcdout "Hex Value:" 'text for the line 1
    Lcdcmdout LcdLine2Home 'set cursor at the beginning of line 2
    Lcdout #an0,#an1,#an2 'formatted text for line 2
    WaitMs 2000 'larger value should be used in real device
    Goto loop 'loop forever


    by the way Im using 3 analog inputs...I want to know the HEX value each of the input and display them on the LCD like FF FF FF 2 bytes only per input and display them together on the LCD. I used the PIC simulator IDE 2.9 with built-in BASIC compiler. Whats the difference between this BASIC from PIC simulator IDE and PicBASIC pro.??? Anyone I appreaciate your help.
    Last edited by winsthon; - 28th December 2003 at 11:44.

Similar Threads

  1. LCD Display
    By lambert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th January 2010, 22:18
  2. assembly in Pic
    By lerameur in forum Off Topic
    Replies: 11
    Last Post: - 1st May 2008, 20:06
  3. LCD display not working properly
    By dilpkan in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd February 2008, 07:43
  4. Replies: 14
    Last Post: - 26th September 2007, 05:41
  5. LCD Display not working - PIC heating...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 24th September 2006, 07:35

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