View previous topic :: View next topic |
Author |
Message |
nina
Joined: 20 Apr 2007 Posts: 111
|
hyperterminal and lcd |
Posted: Tue Apr 21, 2009 3:05 pm |
|
|
Working just with hyperteminal (windows) the code below work perfectly, but when I tried to implement a push button and an lcd together with hyperterminal...it doesn't work. I mean, when I press push button nothing is sent to lcd.
If I take out the if using getc then if I press push button the message is displayed on the lcd.
Here is the code.
Thank you in advance.
Code: | #include <16F877.h>
#use delay(clock=4000000)
#fuses HS, NOWDT,PUT,BROWNOUT,NOLVP
#use rs232(baud=9600, parity=N, xmit=PIN_C6,rcv=PIN_C7)//Configura serial
#include <flex_lcd420.c>
#define LED0 PIN_C0
#define LED1 PIN_C5
#define LED2 PIN_D2
#define botao PIN_E0
char dado;
main(){
lcd_init();
delay_ms(100);
printf("Começando o Programa...");
while(true){
if (input(botao)==1){
delay_ms(1000);
printf(lcd_putc,"Ligado");
output_high(LED2);
delay_ms(100);
}
if (input(botao)==0){
output_low(LED2);
delay_ms(100);
}
if (getchar()=='1'){
printf("MENU 1!!!");
output_high(LED1);
delay_ms(100);
}
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 21, 2009 3:26 pm |
|
|
Describe the external circuit for your push-button. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Apr 21, 2009 3:32 pm |
|
|
The getchar function is blocking, it waits till a character is received on the serial port, leaving no time for processing the key inputs.
change: Code: | if (getchar()=='1'){ | to: Code: | if (kbhit)
{
if (getchar()=='1'){
| The kbhit function will test if a new character is waiting to be processed and only then calls the blocking getchar function. |
|
|
nina
Joined: 20 Apr 2007 Posts: 111
|
hyperterminal and lcd |
Posted: Tue Apr 21, 2009 3:52 pm |
|
|
ckielstra..it work perfectly...thank you very much for your help and cooperation..
nina |
|
|
|