Overclocked
Member
Ive gotten the ADC to work to control the blink rate of a LED, but now I want to try and read the ADC value via USART on my Junebug. Ive gotten it to "talk" with the computer, but It gives me Funky stuff (numbers/letters/symbols) instead of the values I want. Im using a PIC18F1320 and using the pots on the junebug as my voltage source for the ADC.
Note "IntOsc4.bas" is the basic file for the internal osc running at 4Mhz
Code:
Device = 18F1320
Clock = 4 // 4MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF
Include "IntOsc4.bas"
Include "ADC.bas"
Include "USART.bas"
Include "convert.bas"
Function Get_ADC_Sample() As Float // Function to grab the ADC sample
result = ADC.Read(1) //grab a voltage from channel 1 and convert it
result = (result +1)*500
result = result / 1024
End Function
SetBaudrate (br9600)
While True // Create an infinite loop
USART.Write ("DC Volts = ",Get_ADC_Sample ,13,10)
DelayMS (500)
Wend
Note "IntOsc4.bas" is the basic file for the internal osc running at 4Mhz