Hi
Currently working on a project that I need to use a push a button. the requirement is :you press the switch and the LED stays ON for one minute,
below is my attempts. What happening now is that , the LED stays ON for ever , how can I manage to create that one minute delay after the switch is pressed.Any help to resolve this will be appreciate.I am using pic16f877a, and MPLAB xc8
Moderators note : used code tags
Currently working on a project that I need to use a push a button. the requirement is :you press the switch and the LED stays ON for one minute,
below is my attempts. What happening now is that , the LED stays ON for ever , how can I manage to create that one minute delay after the switch is pressed.Any help to resolve this will be appreciate.I am using pic16f877a, and MPLAB xc8
C:
int count=0;
void main() {
TRISD = 0; // configuring output port
TRISB = 1; // configure as input
TMR1H=0x00; // initial count values in timer1 register
TMR1L=0x00;
T1CON=0x01;
while(1)
{
if ( PORTBbits.RB0 ==0) // if the switch still pressed
{
for(count=0;count<=1;count++){
PORTDbits.RD2 = 1;
count=0;
}
}
else{
PORTDbits.RD2 = 0;
}
}
}