Mr.Khiros
Junior Member level 3
- Joined
- Aug 25, 2013
- Messages
- 26
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 176
void main() {
PORTA = 0;
TRISA = 0X01;
PORTB = 0;
TRISB = 0;
ADCON1 = 0x0E;
ADC_Init();
uart1_init(9600);
while (1){
ADRead = (ADC_Get_Sample(0) * 500) >> 10;
WordToStr(ADRead, Display);
UART1_Write_Text(Display);
}
}
void main() {
LCD_Init();
LCD_Cmd(_LCD_CURSOR_OFF);
LCD_Cmd(_LCD_CLEAR);
uart1_init(9600);
while (1){
Lcd_Out(2, 1, Uart1_Read());
}
}
Code C - [expand] 1 2 TRISC = 0x80; PORTC = 0x00;
Lcd_Out(2, 1, Uart1_Read());
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 unsigned char Display[23]; unsigned int strLen = 0; float ADRead, oldVal = 0; void main(){ TRISA = 0X01; PORTA = 0x00; TRISB = 0; PORTB = 0; ADCON1 = 0x0E; UART1_init(9600); Delay_ms(100); while (1){ ADRead = ADC_Read(0) * 3.333333333333333 / 1023; // 1.5V = 306.9 to 1.5V = 1023 // 150 degrees = 5V = 1023 raw // ADC value ADRead = ADRead * 0.1466275659824047; // 1023 to 150 degree C if(oldVal != ADRead){ FloatToStr(ADRead, Display); strLen = strlen(Display); Display[strLen - 1] = 'T'; Display[strLen] = 'x'; Display[strLen + 1] = '\0'; UART1_Write_Text(Display); oldVal = ADRead; } } } unsigned char output[21]; void main(){ TRISB = 0x00; PORTB = 0x00; TRISC = 0x80; PORTC = 0x00; LCD_Init(); LCD_Cmd(_LCD_CURSOR_OFF); LCD_Cmd(_LCD_CLEAR); UART1_init(9600); Delay_ms(100); while (1){ if (UART1_Data_Ready() == 1) { UART1_Read_Text(output, "Tx", 12); // reads text until 'Tx' is found } Lcd_Out(2, 1, output); } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 unsigned char Display[23]; unsigned int strLen = 0; float ADRead, oldVal = 0; void main(){ TRISA = 0X01; PORTA = 0x00; TRISB = 0; PORTB = 0; ADCON1 = 0x83; CMCON = 0x07; CVRCON = 0x00; UART1_init(9600); Delay_ms(100); while (1){ ADRead = ADC_Read(0) * 0.156403 / 1023; if(oldVal != ADRead){ FloatToStr(ADRead, Display); strLen = strlen(Display); Display[strlen - 1] = 'T'; Display[strlen] = 'x'; Display[strlen + 1] = '\0'; UART1_Write_Text(Display); oldVal = ADRead; } } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?