Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

On And Off Switch Hold With Delay, PIC16F628A

Status
Not open for further replies.

eril

Newbie level 6
Joined
Aug 22, 2015
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
95
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.

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.
 

Hello,
At yesterday I forgot to attaching the picture, here a picture.



View attachment ON And OFF Delay Switch.rar On Off Switch With Delay.jpg

Merci.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top