The example shows sampling by an AD converter and sends it as a text via UART1. The realization is carried out by using the mikroC 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
unsigned adcRes; char txt[6]; void Uart1_Write_Text(char *txt_to_wr) { while (*txt_to_wr) Uart1_Write_Char(*(txt_to_wr++)); } void main() { TRISBbits.TRISB10 = 1; // set pin as input - needed for ADC to work Uart1_Init(9600); while (1) { adcRes = Adc_Read(10); WordToStr(adcRes, txt); Uart1_Write_Text(txt); Delay_ms(50); } }//~!