Hi everyone 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 instead I get decimal value. can anyone help me how to do this...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. Anyone I appreaciate your help.
I have a code using BASIC but I dont know how to display the HEX equivalent instead I get decimal value. can anyone help me how to do this...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. Anyone I appreaciate your help.