eril
Newbie level 6
Hello,
This program I founded in other web forum, then I try to a bit modification on the program.
I got this idea, because I seen on my electronic device at home there are power button, the functioned same like this project.
One times you press the button and power will lit then after you want to switch off the button you cant only press it button but you need to hold for few second.
You can use this project for remote your electronic circuit in AC power or PSU, you can put all it together inside the box.
Merci.
This program I founded in other web forum, then I try to a bit modification on the program.
I got this idea, because I seen on my electronic device at home there are power button, the functioned same like this project.
One times you press the button and power will lit then after you want to switch off the button you cant only press it button but you need to hold for few second.
You can use this project for remote your electronic circuit in AC power or PSU, you can put all it together inside the box.
Code:
/*-----------------------------------------------------------------------------------------------------------|
| 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);
}
Merci.