MrDEB
Well-Known Member
trying to read the portA.o ADC value but the dang LED doesn't even blink.
I tested the LCD and it works. Eventually want to read the ADC on portA.0 and portA.1
using Swordfish
I tested the LCD and it works. Eventually want to read the ADC on portA.0 and portA.1
using Swordfish
Code:
Device=18f43k22
Clock = 8 '8MHz
'Config FOSC = INTIO7 'internal oscillator
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTD.2
#option LCD_EN = PORTD.3
// import LCD library...
Include "SetDigitalIO.bas"
'Include "IntOSC.bas"
'Include "LCD.bas"
Include "utils.bas"
Include "LCD.bas"
Include "ADC.bas"
Include "convert.bas"
// read the AD port and scale for 0 - 5 volts...
Function ADInAsVolt() As Word
result = (ADC.Read(0) + 1) * 500 / 1024
End Function
// sampled AD value...
Dim ADVal As Word
Dim led As PORTC.7
// initialise and clear LCD...
ADCON1 = $07 // PORTE as digital (LCD)
TRISA.0 = 1 // configure AN0 as an input
ADCON1.7 = 1 // set analogue input on PORTA.0
DelayMS (500)
LCD.Cls
Output(led)
SetAllDigital
// main program loop...
While true
led=1
DelayMS(500)
led=0
DelayMS(500)
ADVal = ADInAsVolt
LCD.MoveCursor (1,1)
LCD.Write("DC Volts = ", DecToStr(ADVal / 100), ".", DecToStr(ADVal, 2), " ")
DelayMS(2500)
Wend