
The example shows sampling by an AD converter and sends it as a text via UART1. The realization is carried out by using the mikroBasic compiler for dsPIC30F microcontrollers. Fig. 13-4 shows the connection of a dsPIC30F6014A microcontroller for sampling the voltages of the sliding contact of a potentiometer connected to the pin AN10 and sending it as a text via UART1.
Fig. 13-4 Connection of a dsPIC30F6014A device in order to sample on pin AN10
program ADC_test
dim adcRes as word
txt as string[5]
main:
TRISB.10 = 1 ' set pin as input - needed for ADC to work
Uart1_Init(9600)
while true
adcRes = Adc_Read(10)
WordToStr(adcRes, txt)
Uart1_Write_Text(txt)
Delay_ms(50)
wend
end.