Buenas a todos los miembros.
Tenia una duda acerca de como podia escribir numeros con pulsadores en un lcd. Resulta que automaticamente si o si tengo que escribir el numero 123456789 porque no puedo alternar los mismos. Mi pregunta era simple. Queria saber como poder cambiar el orden desde los pulsadores. Aca dejo el codigo:
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use standard_io(A)
#use standard_io(B)
#use standard_io(C)
#include <stdlib.h>
#include <string.h>
#include <lcd.c>
void teclado();
void teclado() {
do{
if(!input(PIN_B0)){ //¿se ha pulsado up?
while(!input(PIN_B0)){} //elimina rebotes
lcd_putc("1");
;
}
if(!input(PIN_B1)){ //¿se ha pulsado up?
while(!input(PIN_B1)){} //elimina rebotes
lcd_putc("2");
}
if(!input(PIN_B2)){ //¿se ha pulsado up?
while(!input(PIN_B2)){} //elimina rebotes
lcd_putc("3");
}
if(!input(PIN_B3)){ //¿se ha pulsado up?
while(!input(PIN_B3)){} //elimina rebotes
lcd_putc("4");
}
if(!input(PIN_B4)){ //¿se ha pulsado up?
while(!input(PIN_B4)){} //elimina rebotes
lcd_putc("5");
}
if(!input(PIN_B5)){ //¿se ha pulsado up?
while(!input(PIN_B5)){} //elimina rebotes
lcd_putc("6");
}
if(!input(PIN_B6)){ //¿se ha pulsado up?
while(!input(PIN_B6)){} //elimina rebotes
lcd_putc("7");
}
if(!input(PIN_A0)){ //¿se ha pulsado up?
while(!input(PIN_A0)){} //elimina rebotes
lcd_putc("8");
}
if(!input(PIN_A1)){ //¿se ha pulsado up?
while(!input(PIN_A1)){} //elimina rebotes
lcd_putc("9");
}
if(!input(PIN_A2)){ //¿se ha pulsado up?
while(!input(PIN_A2)){} //elimina rebotes
lcd_putc(".");
}
if(!input(PIN_A3)){ //¿se ha pulsado up?
while(!input(PIN_A3)){} //elimina rebotes
lcd_putc("\b");
}
if(!input(PIN_A4)){ //¿se ha pulsado up?
while(!input(PIN_A4)){} //elimina rebotes
lcd_putc("0");
}
if(!input(PIN_C0)){ //¿se ha pulsado up?
while(!input(PIN_C0)){} //elimina rebotes
lcd_putc("-");
}
}while(input(PIN_A5)); //apretas enter y..
while(!input(PIN_A5)){} //elimina rebotes
}
void main() {
set_tris_A(0x3F);
set_tris_B(0x3F);
set_tris_C(0x3F);
lcd_init();
lcd_putc("Primer digito\n");
teclado();
lcd_putc("\fSegundo digito\n");
teclado();
}
muchas gracias a los integrantes del foro!
