void main() { int i; trisb=0; portb=0; Lcd_Init(); // Initialize LCD UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize while (1) // Endless loop { if (UART1_Data_Ready()) // If data is received, { for(i=0;i<100;i++) { uart_rd[i]= UART1_Read(); } for(i=0;i<100;i++) { Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,uart_rd[i]); delay_ms(10000); } } } }
void main(void) { clock_int_4MHz(); ADCON1 = 15; lcd_ini(); Lcd_Cmd(LCD_CLEAR); Lcd_Cmd(LCD_CURSOR_OFF); tempo_ms(100); lcd_escreve(1, 2, "Contagem:"); tempo_ms(500); for(i=110; i>0; i--) { sprintf(buffer1,"%3d",i); //Right aligned text lcd_escreve2(1, 11, buffer1); tempo_ms(100); } Lcd_Cmd(LCD_CLEAR); tempo_ms(500); lcd_escreve(2, 4, "By SanUSB"); while(1){} }
void main(){ ADCON1 = 0b00001110; // HABILITA CANAL AN0 E AN1 TRISA.RA0 = 1; Lcd_Init (); // START LCD Lcd_Cmd(_Lcd_Clear); // CLEAR LCD Lcd_Cmd(_LCD_CURSOR_OFF); // TURN OFF LCD CURSOR ADC_Init(); while(1){ adc_rd = ADC_Read(0); // GET ADC VALUE FROM 1ST CHANNEL EEPROM_Write(0x08, adc_rd); //ESCREVE "adc_rd" NA POSICAO 0x08 DA EEPROM IntToStr(adc_rd, adcprint); // CONVERSION TO STRING Lcd_out(1,1,"COUNTS..: "); Lcd_Out_Cp(adcprint); // PRINTS ADC STEPS IN LCD FIRST ROW if (diff != adc_rd){ BarSegmentNum = adc_rd /(1023 / 16); // CALCULATE NUMBERS OF BAR GRAPH SEGMENTS Lcd_out(2,1," "); // CLEARS LCD SECOND ROW for (i = 0; i < BarSegmentNum; i++){ // LOOP TO PRINT EACH BAR SEGMENT IN SECOND ROW CustomChar(2, i+1);}} // PRINT CUSTOM CHARACTER FOR BARGRAPH SEGMENT Delay_ms(750); // STABILIZE LCD DISPLAY diff = adc_rd; // LCD SHOWS EEPROM VALUE ADCeer = EEPROM_Read(0x08); // LE A POSICAO 0x08 DA EEPROM ShortToStr (ADCeer, ADCeerSTR); //Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD Lcd_Out(2, 1, ADCeerSTR); Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD } // END WHILE } // END MAIN
void inicializar(){ ANSEL = 0; ANSELH = 0; Keypad_Init(); // Initialize Keypad Lcd_Init(); // Initialize Lcd Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off }
// Set the cursor to a particular place and line void Lcd_Set_Cursor(char a, char b) { char temp,z,y; if(a == 1) { temp = (char) (0x80 + b - 1); z = temp>>4; y = temp & 0x0F; Lcd_Cmd(z); Lcd_Cmd(y); }
void main() { Lcd_Init(); Foto_ADC_Init(); Config_ptos(); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1, 1, "9CM11-Volmetro"); delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); while(1){ Proceso(); Proceso2(); } }
void main() { Lcd_Init(); Config_ptos(); Config_adc(); Config_UART1(); Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1, 1, "9CM11-Termometro"); delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); while(1){ Proceso(); } }
void main() { char txt[7]; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off TRISB = 0b00010000; INTCON.GIE = 1; //Global Interrupt Enable INTCON.RBIF = 0; //Clear PORTB On-Change Interrupt Flag INTCON.RBIE = 1; //Enable PORTB On-Change Interrupt Lcd_Out(1,1,"Developed By"); Lcd_Out(2,1,"CELAB"); Delay_ms(3000); Lcd_Cmd(_LCD_CLEAR); T1CON = 0x10; //Initializing Timer Module while(1) { TMR1H = 0; //Sets the Initial Value of Timer TMR1L = 0; //Sets the Initial Value of Timer PORTB.F0 = 1; //TRIGGER HIGH Delay_us(10); //10uS Delay PORTB.F0 = 0; //TRIGGER LOW while(!PORTB.F4); //Waiting for Echo T1CON.F0 = 1; //Timer Starts while(PORTB.F4); //Waiting for Echo goes LOW T1CON.F0 = 0; //Timer Stops a = (TMR1L | (TMR1H<<8)); //Reads Timer Value a = a/58.82; //Converts Time to Distance a = a + 1; //Distance Calibration\ if(a>=2 && a<=400) //Check whether the result is valid or not { IntToStr(a,txt); Ltrim(txt); Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"Distance = "); Lcd_Out(1,12,txt); Lcd_Out(1,15,"cm"); } Delay_ms(400); } }
void moverEnAutomatico(){ uart_rd_temp = ' '; bandera_automatico = 1; /* Con esta bandera se valida en la interrupcion que hacer cuando ocurre un choque. */ Lcd_Cmd(_LCD_CLEAR); Lcd_Out(2,6,txtAutomatic); /* Inicio de movimiento en automatico hacia adelante. */ RC1_bit = 1; RC2_bit = 1; RC5_bit = 0; RC4_bit = 0; cargarDato(); while (uart_rd_temp != 'e') { /* Si se le envía e se sale de modo automatico. */ waitSignal(); cargarDato(); /* Al salir de modo automatico paramos los motores.*/ if(uart_rd_temp == 'e') { RC1_bit = 0; RC2_bit = 0; RC5_bit = 0; RC4_bit = 0; } } pararVehiculo(); bandera_automatico = 0; /* al enviar e se sale de modo automatico.*/ }
void Proceso(void){ // Lectura del Voutput del sensor LM35 // Mostrando Voutput y su conversion a °C char val[15]; float volts; float grados; char centigrados[15]; adc_value = ADC1_Get_Sample(10); grados = adc_value/cuentas; FloatToStr(grados,centigrados); UART1_Write_Text(centigrados); UART1_Write(13); UART1_Write(10); Lcd_Out(1, 1, centigrados); Lcd_Out(1, 8, "\xDFc"); volts = adc_value; FloatToStr(volts,val); Lcd_Out(2, 15, "V"); Lcd_Out(2, 1, val); delay(0xFFFFF); Lcd_Cmd(_LCD_CLEAR); if (UART1_Data_Ready()) { // If data is received uart_rd = UART1_Read(); // read the received data if (uart_rd == '1'){ LAMPARA = ~LAMPARA; } else if (uart_rd == '2') { VENTILADOR = ~VENTILADOR; } } }
void main(void) { clock_int_4MHz(); habilita_canal_AD(AN0); lcd_ini(); //Lcd_Cmd(LCD_CLEAR); Lcd_Cmd(LCD_CURSOR_OFF); tempo_ms(100); CGRAM_SanUSB(1,sino);//CGRAM_build(monta posicao do caractere especial,vetor do desenho); tempo_ms(300); Lcd_Chr(1, 2, 1); //Lcd_Chr(linha, coluna, posicao do caractere especial); tempo_ms(500); lcd_escreve(1, 3, "Microcontrol"); tempo_ms(500); lcd_escreve(2, 1, "Converte"); tempo_ms(500); while(1) { i= le_AD10bits(0); inverte_saida(pin_b7);inverte_saida(pin_d7); sprintf(buffer1,"%d ",i); lcd_escreve2(2, 12, buffer1); //com buffer tempo_ms(300); //printf("a "); } }
void main() { int i,j,k,l; int count=0; char c; ENTER=1; EXIT=1; TRISD = 0xFF; // PORTD as input Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,"WELCOME:");//Write text'Hello World' in first row c=toChar(count); Lcd_chr(2,1,c); while(1) { if(ENTER == 1) { Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"WELCOME"); count++; if(count == 999) count=0; Delay(500); } if(EXIT == 1) { Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,"THANKS"); count--; if(count == -1) count=0; Delay(500); } i=count; j=i%10; k=i/10; l=i/100; k=k-l*10; c=toChar(j); Lcd_chr(2,3,c); c=toChar(k); Lcd_chr(2,2,c); c=toChar(l); Lcd_chr(2,1,c); } }
void main() { // FUNCAO PRINCIPAL: MAIN ADCON1 = 0x07; // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS CMCON = 7; // DESLIGA COMPARADORES // CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO] TRISA = 0b00000000; PORTA = 0b00000000; TRISB = 0b00000110; // PORTB = 0b00000000; TRISC = 0b00000000; PORTC = 0b00000000; // ESTADOS INICIAIS DOS ACESSORIOS BUZZER = 1; // MENSAGEM INICIAL NO LCD Lcd_Init(); // INICIA O LCD Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD Lcd_Cmd(_LCD_CURSOR_OFF); // DESLIGA O CURSOR Lcd_Out(1, 1, msg_2); Lcd_Out(2, 1, msg_1); Delay_ms(1500); Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD while (1) { if (!INT2) { BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(50); BUZZER = 0; Delay_ms(15); BUZZER = 1; // SIRENE SOA DUAS VEZES CURTAS // EEPROM_Write(unsigned short address, unsigned short data); EEPROM_Write(0x08, 'K'); //ESCREVE "K" NA POSICAO 0x08 DA EEPROM Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD Lcd_Out(1, 1, msg_1); Lcd_Out(2, 1, msg_3); Delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD } else if (!INT1) { BUZZER = 0; Delay_ms(15); BUZZER = 1; // SIRENE SOA UMA VEZ CURTA // EEPROM_Read(unsigned short address); INFO = EEPROM_Read(0x08); // LE A POSICAO 0x08 DA EEPROM ShortToStr (INFO, INFO_s); Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD Lcd_Out(1, 1, msg_1); Lcd_Out(2, 1, msg_4); Delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD Lcd_Out(1,1,INFO_s); Lcd_Out_Cp(" = DECIMAL"); Lcd_Cmd(_LCD_SECOND_ROW); Lcd_Chr_Cp(0+INFO); Lcd_Out_Cp(" = CHARACTER"); Delay_ms(2500); Lcd_Cmd(_LCD_CLEAR);} // LIMPA A TELA DO LCD else { Lcd_Out(1, 1, msg_5); Lcd_Out(2, 1, msg_6); } // FIM ELSE } // FIM WHILE } // FIM MAIN
void Proceso2(void){ char val2[10]; float voltsFotoB; voltsFotoB = FotoB(); FloatToStr(voltsFotoB,val2); Lcd_Out(2, 1, val2); delay(0xFFFFF); Lcd_Cmd(_LCD_CLEAR); }
void main(void) { clock_int_48MHz(); habilita_canal_AD(AN0); lcd_ini(); //Lcd_Cmd(LCD_CLEAR); Lcd_Cmd(LCD_CURSOR_OFF); tempo_ms(100); CGRAM_SanUSB(1,abre1);//CGRAM_build(monta posicao do caractere especial,vetor do desenho); tempo_ms(100); CGRAM_SanUSB(2,fecha1); tempo_ms(100); CGRAM_SanUSB(3,abre2); tempo_ms(100); CGRAM_SanUSB(4,fecha2); tempo_ms(100); CGRAM_SanUSB(5,vazio); tempo_ms(100); CGRAM_SanUSB(6,b1); tempo_ms(100); while(1){ lcd_escreve(1,1,"SanUSB pisca o"); tempo_ms(500); lcd_escreve(2,1,"Led pra voce "); tempo_ms(500); Lcd_Chr(2, 14, 6); //Lcd_Chr(linha, coluna, posicao do caractere especial); tempo_ms(500); for (kl = 1; kl < 16; kl++) { Lcd_Chr(1, kl, 2); tempo_ms(300); Lcd_Chr(1, kl, 1); tempo_ms(300); Lcd_Chr(1, kl, 5); tempo_ms(100); inverte_saida(pin_b7); inverte_saida(pin_d7); } //* kl=16; for (kl = 16; kl > 0; kl--) { Lcd_Chr(2, kl, 4); tempo_ms(300); Lcd_Chr(2, kl, 3); tempo_ms(300); Lcd_Chr(2, kl, 5); tempo_ms(100); inverte_saida(pin_b7); inverte_saida(pin_d7); }//*/ } }
void main() { unsigned int hold; char txt[7]; Lcd_Init(); TRISD = 0x00; //PORTB as output TRISA = 0xFF; //PORTA as input ADCON1 = 0x0E; // Set AN0 channel pin as analog CMCON |= 7; // Disable comparators //ADCON0 = 0b00000000; //ADCON1 = 0b00001110; //ADCON2 = 0b00001000; //ADCON0.ADON = 0x01; ADC_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); while (1){ //ADCON0.GO_DONE=1; //while(ADCON0.GO_DONE!=0); //hold = ((unsigned int)ADRESH)<<8|(ADRESL); hold = ADC_READ(0); LCD_Chr(1,1,5*hold/1024+48); LCD_Chr(1,2,46); LCD_Chr(1,3,(50*hold/1024)%10+48); LCD_Chr(1,4,(20*hold/41)%10+48); //20/41 =~ 500/1024 LCD_Chr(1,5,86); inttostr(hold,txt); LCD_OUT(2,0,TXT); //IntToStr(hold, txt); //Lcd_Out(1,1,txt); delay_ms(180); } }
void main() { uint8 resource; pcontext_t p2; pcontext_t p1; // timer settings TMR0L = 56; TMR0H = 0; T0CON.PSA = 1; T0CON.T0PS0 = 0; T0CON.T0PS1 = 0; T0CON.T0PS2 = 0; T0CON.T0CS = 0; T0CON.T0SE = 0; T0CON.T08BIT = 1; // techRTOS init tech_init(); tech_setInc(100); // 100 us // enable interrupts T0CON.TMR0ON = 1; INTCON.GIE = 1; INTCON.TMR0IE = 1; INTCON.T0IF = 0; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); resource = 1; p1 = tech_cxt(&task1, &resource, 5); p2 = tech_cxt(&task2, &resource, 5); tech_run(); tech_drop(); }
void main(){ Lcd_Init(); // Initialize Lcd Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,6,txt3); // Write text in first row Lcd_Out(2,6,txt4); // Write text in second row Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,1,txt1); // Write text in first row Lcd_Out(2,5,txt2); // Write text in second row Delay_ms(2000); // Moving text for(i=0; i<4; i++) { // Move text to the right 4 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } while(1) { // Endless loop for(i=0; i<8; i++) { // Move text to the left 7 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } for(i=0; i<8; i++) { // Move text to the right 7 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } } }
void main() { char val[5]; char val1[5]; Conf_puertos(); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); //LAMPARA = 1; current_duty = 3900; // initial value for current_duty pwm_period1 = PWM_TIM2_Init(50); PWM_TIM2_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL2); PWM_TIM2_Start(_PWM_CHANNEL2, &_GPIO_MODULE_TIM2_CH2_PA1); FloatToStr(pwm_period1,val); FloatToStr(current_duty,val1); Lcd_Out(1, 1, val); Lcd_Out(2, 3, val1); delay(0xFFFFF); while (1){ //if(GPIOA_IDR.B0){ //LAMPARA = ~LAMPARA; if(current_duty <=6850){ char val1[5]; Delay_ms(1); current_duty = current_duty - 15; // increment current_duty if (current_duty < 1700 ) { // if we increase current_duty greater then possible pwm_period1 value current_duty = 6850; // reset current_duty value to zero } PWM_TIM2_Set_Duty(current_duty, _PWM_NON_INVERTED, _PWM_CHANNEL2); /// set newly acquired duty ratio PWM_TIM2_Start(_PWM_CHANNEL2, &_GPIO_MODULE_TIM2_CH2_PA1); //agregamos que haga el cambio cada vez presionado el boton FloatToStr(current_duty,val1); Lcd_Out(1, 1, val); Lcd_Out(2, 1, val1); //delay(0x1); Lcd_Cmd(_LCD_CLEAR); } Delay_ms(1); // slow down change pace a little } }
void main() { /* Lcd_Init() to initialize the library */ Lcd_Init(); /* In order to print a string on a specific row, colum, use the following function. first number is the line number. second number is the column number. */ Lcd_Out(1, 1, "Jontropati.com"); Delay_ms(1000); // delay- 1 sec /* THis function append some new string from previous string position */ Lcd_Out_CP(" !!!"); Delay_ms(1000); // delay 1 sec /* Clear the LCD display */ Lcd_Cmd(_LCD_CLEAR); /* Below funciton, prints a charecter on specific line, column */ Lcd_Chr(1, 1, 'A'); Delay_ms(1000); /* This function appends a new charecter from previous position. */ Lcd_Chr_CP('B'); while (1) { } }
void main(){ Lcd_init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); I2C1_Init(100000); TRISB.F0=0; TRISB.F1=0; while(1){ Read_Compass(); WordToStr(angle,to_LCD); Lcd_Out(1,1,to_LCD); straight(); // delay_ms(500); // Lcd_Out(1,1,"Piyumal"); //delay_ms(1000); } }
void main() { ADCON1 = 0x07; // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS CMCON = 7; // DESLIGA COMPARADORES // CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO] TRISA = 0b00000000; PORTA = 0b00000000; TRISB = 0b00000110; PORTB = 0b00000000; TRISC = 0b00000000; PORTC = 0b00000000; // TRISD = 0b00000000; PORTD = 0b00000000; // TRISE = 0b00000000; PORTE = 0b00000000; // ESTADOS INICIAIS DOS ACESSORIOS EM USO BUZZER = 1; // MENSAGEM INICIAL NO LCD Lcd_Init(); // INICIA O LCD Lcd_Cmd(_LCD_CLEAR); // LIMPA A TELA DO LCD Lcd_Cmd(_LCD_CURSOR_OFF); // DESLIGA O CURSOR Lcd_Out(1, 1, msg_1); Lcd_Out(2, 1, msg_2); while (1){ BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(150); BUZZER = 0; Delay_ms(15); BUZZER = 1; // SIRENE SOA DUAS VEZES CURTAS Delay_ms(10000);}}
void Display_Time_Core(unsigned char *sec, unsigned char *min, unsigned char *hr, unsigned char *wd, unsigned char *day, unsigned char *mn, unsigned char *year) { // for some other testing unsigned char txtSec[5] = ""; unsigned char txtMin[5] = ""; unsigned char txtHour[5] = ""; unsigned char txtWd[5] = ""; unsigned char txtDay[5] = ""; unsigned char txtMn[5] = ""; unsigned char txtYear[5] = ""; unsigned char txtDisplayRow1[16] = ""; unsigned char txtDisplayRow2[16] = ""; ShortToStr(*sec, txtSec); ShortToStr(*min, txtMin); ShortToStr(*hr, txtHour); ShortToStr(*wd, txtWd); ShortToStr(*day, txtDay); ShortToStr(*mn, txtMn); ShortToStr(*year, txtYear); MakeLastTwoChars(txtSec); MakeLastTwoChars(txtMin); MakeLastTwoChars(txtHour); MakeLastTwoChars(txtWd); MakeLastTwoChars(txtDay); MakeLastTwoChars(txtMn); MakeLastTwoChars(txtYear); strcat(txtDisplayRow1, "DATE:"); strcat(txtDisplayRow1, txtMn); strcat(txtDisplayRow1, "/"); strcat(txtDisplayRow1, txtDay); strcat(txtDisplayRow1, "/"); strcat(txtDisplayRow1, txtYear); strcat(txtDisplayRow1, ":"); strcat(txtDisplayRow1, txtWd); strcat(txtDisplayRow2, "TIME:"); strcat(txtDisplayRow2, txtHour); strcat(txtDisplayRow2, ":"); strcat(txtDisplayRow2, txtMin); strcat(txtDisplayRow2, ":"); strcat(txtDisplayRow2, txtSec); Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,txtDisplayRow1); Lcd_Out(2,1,txtDisplayRow2); }
/* Initializes all globals and sets default bits in registers. */ void initialize(){ C1ON_bit = 0; // Disable comparators C2ON_bit = 0; ANSEL = 0x04; // Configure AN2 pin as analog ANSELH = 0; // Configure other AN pins as digital I/O // Initialize timer 0 to interrupt every 10ms OPTION_REG = 0x86; TMR0 = 100; INTCON = 0xA0; // Init LCD Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); // Initialize globals timerCounter = 0; }
unsigned short obtenerNumero (unsigned short numMax) { unsigned short dig, numero, kp; volverObtenerNumero: dig = 0; numero=0; leerNum: do { kp = Keypad_Key_Click(); if (UART1_Data_Ready()){ kp = UART1_Read(); goto bluetoothRead; } }while (!kp); kp = teclado(kp); bluetoothRead: if(kp == 'A' || kp== 'B' || kp == 'C' ||kp == 'D'){ goto leerNum; }else if (kp != '#' && kp != '*'){ dig++; numero = numero*10 + kp -48; //Lcd_Chr(2, 7+dig, kp); } //}while (numero > numMax && kp != '*' && kp != '#'); if(kp == '#'){ //si presiona numeral se borra el numero goto volverObtenerNumero; }else if (kp == '*' && numero > 0){ //Lcd_Chr(2, 7, (numero+48)); Lcd_Out(2, 1, "Valor guardado"); delay(); }else if (numero > numMax){ Lcd_Cmd(_LCD_CLEAR); Lcd_Out(2, 1, "Se paso de valor maximo"); delay(); goto volverObtenerNumero; } else{ goto leerNum; } return (numero); }
void moverManual(){ uart_rd_temp = ' '; cargarDato(); bandera_automatico = 0; /* Se limpia la bandera de automatico por si acaso. */ while (uart_rd_temp != 'e') { /* Si se le envía e se sale de modo manual */ waitSignal(); cargarDato(); if (uart_rd_temp == 'u' && bandera_mover) { /* Up: En la interrupción para el auto */ Lcd_Out(2,6,txtArriba); avanzarVehiculo(); } else if (uart_rd_temp == 'd' && bandera_mover) { /* Down: */ Lcd_Out(2,6,txtAbajo); moverAtras(); } else if (uart_rd_temp == 'l' && bandera_mover) { /* left: */ Lcd_Out(2,6,txtAbajo); girarIzquierda(); avanzarVehiculo(); } else if (uart_rd_temp == 'r' && bandera_mover) { /* right: */ Lcd_Out(2,6,txtAbajo); girarDerecha(); avanzarVehiculo(); } } pararVehiculo(); Lcd_Cmd(_LCD_CLEAR); Lcd_Out(2,6,"Se salió de modo manual."); Delay_ms(100); uart_rd_temp = ' '; }
void main() { unsigned short kp; int nscale=0; char txt[3]; //initializing scale char scale[3][3]; scale[0][0]='H';scale[0][1]='z';scale[0][2]=' '; scale[1][0]='K';scale[1][1]='H';scale[1][2]='z'; scale[2][0]='M';scale[2][1]='H';scale[2][2]='z'; TRISA= 0; TRISB=0; Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1, 1, "Freq:"); // Write message text on LCD Lcd_Out(1, 14, "Hz"); Lcd_Out(2,1,"Signal Generator"); Keypad_Init(); // Initialize Keypad while(1) { int freq_array[3]={0,0,0}; unsigned long freq; kp=0; kp=Keypad_Key_Click(); if(kp!=0 && kp!=1 && kp!=2) //when any number is pressed { freq_array[0]=freq_array[1]; freq_array[1]=freq_array[2]; freq_array[2]=keyidentifier(kp); freq=100*freq_array[2]+10*freq_array[1]+freq_array[0]; LongToStr(freq,txt); Lcd_Out(1,6,txt); } if(kp==2) //when scale key pressed { if(nscale==2){ nscale=0; } else { nscale=nscale+1; } Lcd_Out(1,14,scale[nscale]); } if(kp==1) //when start is pressed { if(nscale==2) { freq=freq*1000000; } else if(nscale==1) { freq=freq*1000; } else { freq=freq; } set_keyword(freq); send_data_ad9850(); } } }
// Clear the LCD void Lcd_Clear() { Lcd_Cmd(0x00); Lcd_Cmd(0x01); __delay_ms(2); }
void CustomChar(char pos_row, char pos_char) { char i; Lcd_Cmd(64); for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]); Lcd_Cmd(_LCD_RETURN_HOME); Lcd_Chr(pos_row, pos_char, 0);}
void main() { char txt[16]; trisc=0; portc=0; Keypad_Init(); Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); while(1){ lcd_out(1,1,"EnterTemp="); x=0; do{ kp = 0; kp = Keypad_Key_Click(); } while(!kp); switch (kp) { case 1: kp = 49;previous_value=1;break; // 1 case 2: kp = 50;previous_value=2;break; // 2 case 3: kp = 51;previous_value=3;break; // 3 case 4: kp = 65;break;// A case 5: kp = 52;previous_value=4;break;// 4 case 6: kp = 53;previous_value=5;break; // 5 case 7: kp = 54;previous_value=6;break; // 6 case 8: kp = 66;break; // B case 9: kp = 55;previous_value=7;break; // 7 case 10: kp = 56;previous_value=8;break; // 8 case 11: kp = 57;previous_value=9;break; // 9 case 12: kp = 67;break; // C case 13: kp = 42;break; // * case 14: kp = 48;previous_value=0;break;// 0 case 15: kp = 35;break; // # case 16: kp = 68;break; // D } if(kp==42&&x==0){ //clear the screen lcd_cmd(_lcd_clear); shift=10; first=1000; second=1000; third=1000; desired_temp=0; previous_value=0; get_temp=0; real_temp=0; kp=0; x=1; } if(first==1000&&second==1000&&third==1000&&kp!=35&&x==0){ first=previous_value; shift++; lcd_chr(1,shift,kp); } else if(first!=1000&&second==1000&&third==1000&&kp!=35&&x==0){ second=previous_value; shift++; lcd_chr(1,shift,kp); } else if(first!=1000&&second!=1000&&third==1000&&kp!=35&&x==0){ third=previous_value; shift++; lcd_chr(1,shift,kp); } if(kp==35&&x==0){ shift++; lcd_chr(1,shift,kp); delay_ms(1000); if(first!=1000&&second==1000&&third==1000){ desired_temp=first; } else if(first!=1000&&second!=1000&&third==1000){ first=first*10; desired_temp=first+second; } else if(first!=1000&&second!=1000&&third!=1000){ first=first*100; second=second*10; desired_temp=first+second+third; } while(kp==35&&x==0){ lcd_cmd(_lcd_clear); get_temp=adc_read(0); real_temp=(500.0*get_temp)/1023; inttostr(real_temp,txt); lcd_out(2,1,"RealTemp="); lcd_out_cp(txt); while(real_temp>desired_temp){ get_temp=adc_read(0); real_temp=(500.0*get_temp)/1023; inttostr(real_temp,txt); lcd_out(2,1,"RealTemp="); lcd_out_cp(txt); ac_fan=1; lcd_out(1,1,"cooling"); } while(real_temp<=desired_temp){ get_temp=adc_read(0); real_temp=(500.0*get_temp)/1023; inttostr(real_temp,txt); lcd_out(2,1,"RealTemp="); lcd_out_cp(txt); ac_fan=0; lcd_out(1,1,"process done"); lcd_out(2,1,"RealTemp="); lcd_out_cp(txt); } } } } }