Ejemplo 3
//de segundos que debe temporizar y luego enter, que se dará con la tecla #.
#INCLUDE
#USEDELAY(CLOCK=4000000)
#FUSES XT,NOPROTECT,NOWDT,NOBROWNOUT,NOPUT,NOLVP
#DEFINE USE_PORTB_LCD TRUE
#DEFINE USE_PORTB_KBD
#INCLUDE
#INCLUDE
#BYTE PORTC= 7
#BYTE WPUB=0x95
#DEFINELED PORTC,7
CHAR K;
INT TIEMPO;
VOID MAIN()
{
PORT_B_PULLUPS(TRUE); /*En el programa principal habilitar las resistencias
pullup del puertoB, con esto simplemente se habilitan
internamente unas resistencias del puerto B a +V.*/
WPUB=0B00011110; //Configura los pines RB1, RB2, RB3 yRB4 con pullup
SET_TRIS_C(0B01111111);
LCD_INIT();
KBD_INIT(); //Inicializar el driver del teclado en el programa principal
LCD_PUTC("\f");WHILE(TRUE)
{
BIT_CLEAR(LED); //Apagar el led
LCD_GOTOXY(1,1); //En la fila 1, columna 1
LCD_PUTC("INGRESETIEMPO:"); //Mostrar el mensaje “INGRESE TIEMPO”
K=KBD_GETC(); /*Llamar la función del teclado y almacenar el valor
digitadoen una variable tipo carácter. Si no se oprime
ninguna tecla el teclado retornara el carácter nulo.*/
LCD_GOTOXY(6,2);
TIEMPO=48;WHILE(TIEMPO==48)
{
K=KBD_GETC();
WHILE( (K=='\0')) //si no se oprime ninguna tecla sigue llamando al teclado{
K=KBD_GETC();
}
IF((K!='*')&&(K!='#'))
{
LCD_PUTC(K);
TIEMPO=K-48;...
Regístrate para leer el documento completo.