Qaisar Azeemi
Full Member level 5
- Joined
- Feb 11, 2011
- Messages
- 315
- Helped
- 16
- Reputation
- 32
- Reaction score
- 15
- Trophy points
- 1,298
- Location
- Peshawar, Pakistan, Pakistan
- Activity points
- 3,829
Hi;
i am using four buttons with my PIC16F877A microcontroller. i am using button function if( Button(&PORTD,0,100,0)) in order to detect Logic 0 by a keypress but it is not detecting it. here is my code:
please tell me where i am going wrong in Button function. please don't care of lcd or scroll functions code missing; but i think i am missing some thing in button function. i am just having the problem in button function. my hardware is functioning well, means no problem in there in soldering or wiring connections.
waiting for your kind help, and any help will be much appreciated.
Thanking you in anticipation
Regards
Qaisar Azeemi
i am using four buttons with my PIC16F877A microcontroller. i am using button function if( Button(&PORTD,0,100,0)) in order to detect Logic 0 by a keypress but it is not detecting it. here is my code:
Code:
// INPUTS
#define enter PORTD.F0
#define reset PORTD.F1
#define up PORTD.F2
#define down PORTD.F3
//CONSTANTS
#define ms 100 // for button debounce
int scroll_up( int , int );
int scroll_down( int , int );
void main()
{
unsigned int i=0; //i=loops
// INPUTS:
TRISD.F0=1; // ENTER
TRISD.F1=1; // RESET
TRISD.F2=1; // UP
TRISD.F3=1; // DOWN
TRISA = 0xff; // port A as input
while(1)
{
if(Button(&PORTD,0,ms,0)) //when Enter is pressed
{
int itrue=1;
x=0;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,CopyConst2Ram(msg,ep)); //enter passward
Delay_ms(t);
while(Button(&PORTD,0,ms,0)) // press enter
{ x++;
Lcd_Out(2,x,CopyConst2Ram(msg,asteric)); //*
if(x==4)
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,1,CopyConst2Ram(msg,pw)); //please wait
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,CopyConst2Ram(msg,gwt)); // Generator warm up time
inc=0; //for selection of variable
itrue=1; // Entring and Exiting main menu
opt=1; // option b/w selection number or variable
while(itrue)
{
if(Button(&PORTD,0,ms,0)) // pressing enter to enter time
{
opt=0;
Lcd_Out(2,1,CopyConst2Ram(msg,sp));
}
if(Button(&PORTD,1,ms,0)) //press reset to exit
itrue=0;
if(Button(&PORTD,2,ms,0)) //up
inc=scroll_up(opt,inc);
if(Button(&PORTD,3,ms,0)) // down
inc=scroll_down(opt,inc);
}
x++;
} //if
} //while
Delay_ms(1000);
}
} // while
} // main
please tell me where i am going wrong in Button function. please don't care of lcd or scroll functions code missing; but i think i am missing some thing in button function. i am just having the problem in button function. my hardware is functioning well, means no problem in there in soldering or wiring connections.
waiting for your kind help, and any help will be much appreciated.
Thanking you in anticipation
Regards
Qaisar Azeemi