/*-----------------------------------------------------------------------------------------------------------|
| This project I founded in Mikroelektronika Forum, someone is a having a problem with this issue, |
| I do some a bit modification to get this function. |
| Compiler : MikroC PIC, Mikroelektronika. |
| Processor : PIC16F628A. |
| Crystal : 4 Mhz. |
| Description of Code : Press one times, led will be Up and press and hold few second then power will be off|
|----------------------------------------------------------------------------------------------------------*/
sbit LED_PW at RB0_bit; //Definisi ke PORTB_RB0
sbit LED_BRD at RB1_bit; //Definisi ke PORTB_RB1
sbit Switch at RA0_bit; // Saklar ke PORTA_RA0
void main()
{
CMCON = 0x07 ; // Komparator Off
TRISb = 0b00000000; // PORTB Sebagai Output
PORTB = 0b00000000; // Clear PORTB
TRISA = 0b11111111; // PORTA Sebagai Input
LED_PW, LED_BRD = 0; // RB0 Dan RB1 Sebagai Output
do
{
if (Button(PORTA, 0, 20, 0 ))
{
if (!Switch)
{
LED_PW = 1, LED_BRD = 1;
Delay_ms (400);
{
if (!Switch)
LED_PW = 0, LED_BRD = 0;
}
}while (!Switch);
}
} while (1);
}