# Check and link variables continuously

**URL:** <https://forum.universal-robots.com/t/check-and-link-variables-continuously/23595>\
**Category:** Technical Questions\
**Created:** [September 2, 2022, 7:13am UTC](https://forum.universal-robots.com/t/check-and-link-variables-continuously/23595 "2022-09-02T07:13:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon75290446](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@anon75290446](https://forum.universal-robots.com/u/anon75290446)\
**Post date:** [September 2, 2022, 7:13am UTC](https://forum.universal-robots.com/t/check-and-link-variables-continuously/23595/1 "2022-09-02T07:13:38Z")

</div>

Hello,

I need to check a Variable for 5 Sec. so that the Sensor is not activated by mistake.

the Programm should only run if the Sensor gets the Signal for that time.

Should i use a Sub-Programm?

---

<div class="post-metadata">

**Author:** ![m.hammerton](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@m.hammerton](https://forum.universal-robots.com/u/m.hammerton)\
**Post date:** [September 5, 2022, 10:42am UTC](https://forum.universal-robots.com/t/check-and-link-variables-continuously/23595/2 "2022-09-05T10:42:38Z")

</div>

Kurt.stahl,

You could monitor the input in a thread.  
when the input goes high start a timer  
when the input goes low stop and reset the timer  
remember to add a sync() into the thread  
then in your program  
check if the input is high and timer to be equal or grater than 5 sec.

so if the input is activated for less than 5 sec the if statement in the prog won’t be true because the timer will keep being reset to 0  
if the input is activated for 5 sec or more the timer will start continue to count until the Digital input is low again. (or you stop the timer somewhere else in the program).

![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/f/fd67d8422d0f76a73deae2c71d599e1c5a606f70.png)

---

<div class="post-metadata">

**Author:** ![efn](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@efn](https://forum.universal-robots.com/u/efn)\
**Post date:** [September 5, 2022, 11:03am UTC](https://forum.universal-robots.com/t/check-and-link-variables-continuously/23595/3 "2022-09-05T11:03:34Z")

</div>

Another simple way to achieve this is to use an if-command with the continuously checking of the expression in a thread such as this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/5/55664f1cbb4e3f3e141e546653cebce03c5259fe.png)
