# Timer for Boolean Tags

**URL:** <https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023>\
**Category:** Ignition\
**Created:** [December 12, 2021, 9:23pm UTC](https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023 "2021-12-12T21:23:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbpingston](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jbpingston](https://forum.inductiveautomation.com/u/jbpingston)\
**Post date:** [December 12, 2021, 9:23pm UTC](https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023/1 "2021-12-12T21:23:37Z")

</div>

I am trying to come up with the cleanest way to set a bool tag true for x amount of time then set it back to false once that time is made.

Ex. - Click button, set BOOL true, after 30 seconds change value of BOOL to False.

---

<div class="post-metadata">

**Author:** ![wbaker](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wbaker/32/85315_2.png) [@wbaker](https://forum.inductiveautomation.com/u/wbaker)\
**Post date:** [December 12, 2021, 11:59pm UTC](https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023/2 "2021-12-12T23:59:04Z")

</div>

In perspective you could:

```auto
import time

MyTag ==1
time.sleep(30)
MyTag == 0

```

You’d need to create a bi-directional tag binding on a key value under the custom properties of the button and then trigger the above script on a button click.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 13, 2021, 2:32am UTC](https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023/3 "2021-12-13T02:32:40Z")

</div>

That blows up if you click multiple times or from miltiple clients. If you are using any form of sleep, you are screwing up. Have your button set a timestamp in a memory tag. Have a gateway timer script check regularly to update the boolean.

Just because Perspective _ **lets you** _ use sleep() doesn’t mean it is a good idea.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [December 13, 2021, 3:27am UTC](https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023/4 "2021-12-13T03:27:34Z")

</div>

Sounds like the perfect job for a PLC.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [December 13, 2021, 7:38am UTC](https://forum.inductiveautomation.com/t/timer-for-boolean-tags/54023/5 "2021-12-13T07:38:46Z")

</div>

You can also set an alarm on the tag delayed for the duration that you want to allow it to be on.

On alarm active, you can then write itself to false again. I use this for non-critical items.

Anything important needs a PLC involved.
