# I can make a sub that stops a count

**URL:** <https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216>\
**Category:** XOD Programming Questions\
**Created:** [August 14, 2022, 9:20pm UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216 "2022-08-14T21:20:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwlee-lv](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@rwlee-lv](https://forum.xod.io/u/rwlee-lv)\
**Post date:** [August 14, 2022, 9:20pm UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/1 "2022-08-14T21:20:36Z")

</div>

I can do this with C in Arduino IDE I’m trying to find a way to stop a counter when the number reaches a certain number!

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [August 14, 2022, 10:50pm UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/2 "2022-08-14T22:50:04Z")

</div>

Count increments when count-INC gets a pulse. You can stop the count by running that pulse through a gate node and only enable gate when count is less than your Max value. Since the output of count will affect input of count, you will need a defer node to loop back up in your patch.

---

<div class="post-metadata">

**Author:** ![rwlee-lv](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@rwlee-lv](https://forum.xod.io/u/rwlee-lv)\
**Post date:** [August 15, 2022, 3:01am UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/3 "2022-08-15T03:01:48Z")

</div>

So one of the things great things about writing C is you can control bits and port pins very easy, there isn’t a node that will pulse out a Boolean value unless I’m missing something here. I’m trying to momentarily reset a pin on a CD4017!

---

<div class="post-metadata">

**Author:** ![rwlee-lv](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@rwlee-lv](https://forum.xod.io/u/rwlee-lv)\
**Post date:** [August 15, 2022, 3:05am UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/4 "2022-08-15T03:05:39Z")

</div>

I’m using the digital-write node, I only need to pull the port pin high for a couple of milli second and then reset it low again.

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [August 15, 2022, 1:56pm UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/5 "2022-08-15T13:56:27Z")

</div>

You can try connecting delay-ACT to value for digital-write, then set delay-T to 0.002. In theory, it should work, but I don’t know how well delay will handle that small a value.

---

<div class="post-metadata">

**Author:** ![rwlee-lv](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@rwlee-lv](https://forum.xod.io/u/rwlee-lv)\
**Post date:** [August 16, 2022, 2:57am UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/6 "2022-08-16T02:57:00Z")

</div>

So I tried it and it worked for 5 minutes then it stopped working I tried a new Xod window and it wouldn’t work anymore even on another board. I have no idea at this point I’m going back to Arduino IDE

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [September 15, 2022, 2:57am UTC](https://forum.xod.io/t/i-can-make-a-sub-that-stops-a-count/6216/7 "2022-09-15T02:57:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
