0 Members and 1 Guest are viewing this topic.
sbit LCD_RS at RB5_bit;sbit LCD_EN at RB4_bit;sbit LCD_D7 at RB0_bit;sbit LCD_D6 at RB1_bit;sbit LCD_D5 at RB2_bit;sbit LCD_D4 at RB3_bit;sbit LCD_RS_Direction at TRISB5_bit;sbit LCD_EN_Direction at TRISB4_bit;sbit LCD_D7_Direction at TRISB0_bit;sbit LCD_D6_Direction at TRISB1_bit;sbit LCD_D5_Direction at TRISB2_bit;sbit LCD_D4_Direction at TRISB3_bit;signed int Radc = 0;float Tem = 0; char Text2[15];char Text[15]; char txt1[] = "Temp: ";char txt2[] = "Act:";unsigned int i;int b;void main(){ ANSEL = 0b00000001; ANSELH = 0; TRISA0_bit = 1; TRISA1_bit = 1; TRISA2_bit = 1; TRISA3_bit = 0; C1ON_bit = 0; C2ON_bit = 0; i = 30; ADC_Init(); PORTA = 0; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1, txt1); Lcd_Chr(1,14,223); Lcd_Chr(1,15,'C'); Lcd_Chr(2,10,223); Lcd_Out(2,1,txt2); while(1){ Radc = ADC_Get_Sample(0); if(RA1_bit == 1){ // Boton para incrementar la temperatura de activacionDelay_ms(10);i++;}if(RA2_bit == 1){ // Boton para decrementar la temperatura de activacionDelay_ms(10);i--;} if(Tem >= i ){RA3_bit = 1; // aqui se enciende la ventilacion cuando la temperatura de activacion es igual o mayor a la lectura de temperaturaLcd_Out(2,12,"ONN");}if(Tem <= i-10){ // Aqui es donde se modifica el parametro de apagado de la refrigeracion, el numero "-X" puede cambiarse para queRA3_bit = 0; // se apage la refrigeracion al llegar a esa temperatura, en este caso cuando la temperatura es 10 grados menor queLcd_Out(2,12,"OFF"); // la temperatura de acticaciĆ³n} Tem = (float)(Radc/2.05); // Conversion de lectura del ADC a valor de temperatura en grados centigrados IntToStr(i,Text2); FloatToStr(Tem,Text); Lcd_Out(2,6,Text2); Lcd_Out(1,6, Text); Delay_ms(300); }}
Im putting in to be on "2,2,6" but instead is displaying on "2,2,10".
Lcd_Out(2,6,Text2 + 3); // only show last 3 characters of 6 character number
Ltrim ( Text2 );