# Big Button gate length

**URL:** <https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461>\
**Category:** DIY STUFF\
**Created:** [January 5, 2022, 6:23am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461 "2022-01-05T06:23:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 5, 2022, 6:23am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/1 "2022-01-05T06:23:31Z")

</div>

Hey,

Im building a Big Button. I am no coder…

How do I change the total OUTPUT trigger length to be longer? I dont really need it per channel, just a global variable.

Is it easy to make it a variable length, either switched for ‘short’ / ‘long’ or variable via a pot? How?

maybe its this delay (10), and I can make it bigger?:

digitalWrite(OUT1,Sequence [1+BankArrayShift1][BankPush1 + NewKnobValue1] || (Fill1));  
digitalWrite(OUT2,Sequence [2+BankArrayShift2][BankPush2 + NewKnobValue2] || (Fill2));  
digitalWrite(OUT3,Sequence [3+BankArrayShift3][BankPush3 + NewKnobValue3] || (Fill3));  
digitalWrite(OUT4,Sequence [7+BankArrayShift4][BankPush4 + NewKnobValue4] || (Fill4));  
digitalWrite(OUT5,Sequence [8+BankArrayShift5][BankPush5 + NewKnobValue5] || (Fill5));  
digitalWrite(OUT6,Sequence [9+BankArrayShift6][BankPush6 + NewKnobValue6] || (Fill6));  
delay(10);  
digitalWrite(OUT1,LOW);  
digitalWrite(OUT2,LOW);  
digitalWrite(OUT3,LOW);  
digitalWrite(OUT4,LOW);  
digitalWrite(OUT5,LOW);  
digitalWrite(OUT6,LOW);  
buttonState = LOW;

cheers

Lance

---

<div class="post-metadata">

**Author:** ![Dud](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/dud/32/610_2.png) [@Dud](https://lookmumnocomputer.discourse.group/u/Dud)\
**Post date:** [January 5, 2022, 10:13am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/2 "2022-01-05T10:13:28Z")

</div>

I’m far from coding too 😁  
but my first thought is that it is a Trigger signal and not a Gate signal, so not sure if this is possible, but it is only a thought, the reality is often different.

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 5, 2022, 10:15am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/3 "2022-01-05T10:15:57Z")

</div>

Yes, I just want a longer trigger for my light based synth stuff as LDRs are slow, and also longer flashes may lokk cooler.

My first idea was to analog it with caps and buffers ala the MFOS Cmos strategy, but that uses 2 chips when it really seems like there should. Be a digital programming solution for something so simple.

---

<div class="post-metadata">

**Author:** ![Dud](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/dud/32/610_2.png) [@Dud](https://lookmumnocomputer.discourse.group/u/Dud)\
**Post date:** [January 5, 2022, 10:24am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/4 "2022-01-05T10:24:30Z")

</div>

If the code solution don’t work, here’s a simple Trigger to Gate schem from Niklas Rönneberg

 ![clk2gate](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/3X/3/7/3783629a99d462351872aadf7fccc83c7970f612.png)

![clk2gate_components](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/3X/9/6/9604f52475b2517a9381e44285a1b0df5e2f0092.png)

await the advice of the coding specialist 🙂

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 5, 2022, 10:35am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/5 "2022-01-05T10:35:05Z")

</div>

Nah thats waaaaay too much to do per channel!

Im pretfy sure that code bit i pasted is corrext, but it may also slow down the whole provram if i change it. I may get to test it tonight. If i do have to resort to analog, ill be doing the pulse stretcher from Ray Wilson here.

> **[Music From Outer Space Your Synth-DIY Headquarters](http://musicfromouterspace.com/index.php?CATPARTNO=&PROJARG=ELECTRONICS%2Fmickeymouselogic.html&MAINTAB=SYNTHDIY&SONGID=NONE&PLAYONLOAD=FALSE&VPW=&VPH=&CATMOBISTATUS=&SYNTHDIYSTATUS=CONTENT&SEARCHTERM=)**
>
> Music From Outer Space is your synth-diy headquarters. Analog synthesizer plans and schematics.

Which will need just 2 \* 40106 plus a cap and r per channel. But thar still seems crazy vs just knowing which line of code to change…

---

<div class="post-metadata">

**Author:** ![eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@eric](https://lookmumnocomputer.discourse.group/u/eric)\
**Post date:** [January 5, 2022, 10:54am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/6 "2022-01-05T10:54:35Z")

</div>

Changing that delay(10); instruction will increase the length of the pulse, however…

During that time, the Arduino isn’ t doing anything, not even watching the buttons, so it may become really slugish to respond to user input.

Just try it and see if you can stand the slower interaction…

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 5, 2022, 11:53am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/7 "2022-01-05T11:53:21Z")

</div>

Yes. That is what i feared…

Ill have a play and see how it works. Id rathrr have responsive with more supprt chips than laggy…

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [January 5, 2022, 12:15pm UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/8 "2022-01-05T12:15:53Z")

</div>

I do this in my MIDI to CV code:

Declare a global

```auto
unsigned long trigTimer = 0;

```

Near the top of the loop:

```auto
  if ((trigTimer > 0) && (millis() - trigTimer > 20))
    {
      digitalWrite(TRIG, LOW); // Set trigger low after 20 msec
      trigTimer = 0;
    }

```

and then at the place in the code where the trigger is to be generated

```auto
  digitalWrite(TRIG, HIGH);
  trigTimer = millis();

```

So the Nano stays awake and working during the time the trigger is on.

---

<div class="post-metadata">

**Author:** ![Caustic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/caustic/32/15588_2.png) [@Caustic](https://lookmumnocomputer.discourse.group/u/Caustic)\
**Post date:** [January 5, 2022, 3:03pm UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/9 "2022-01-05T15:03:37Z")

</div>

I’m betting we could also refactor these with interrupts to decouple the interface with the running of the sequencer.

I need to build one of these soon.

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [January 5, 2022, 3:08pm UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/10 "2022-01-05T15:08:22Z")

</div>

Yeah, I did that with the GEAR sequencer. I ended up having to put more into the interrupt handler than I liked but it seems to work. Before doing that the user interface really bogged down the sequencing. I switched the digitalWrites over to DirectIO library calls which are supposed to be much faster.

But that’s a big project. If the easy way works, it works.

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 5, 2022, 9:06pm UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/11 "2022-01-05T21:06:12Z")

</div>

This is super guys. Thanks a lot. Ill try it tonight or next week.

There are lots of forks of this out there now when you search, is there any particular vesion you coders would recommend over another to base it on?

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 15, 2022, 4:59am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/12 "2022-01-15T04:59:55Z")

</div>

ok,

what with parenting and COVID and the inevitable electronics letting off the wrong kind of smoke, its taken me over a week to get back to this.  
i also have _no idea_ about what I’m really doing, and I don’t actually know where to put this code. I tried puttinig it here:

void loop()  
{  
RecordButtonState = digitalRead(BigButton);  
DeleteButtonState = digitalRead(ButtonDelete);  
ClearButtonState = digitalRead(ButtonClear);  
ResetButtonState = digitalRead(ResetButton);  
FillButtonState = digitalRead(FillButton);  
ButtonBankSelectState[BankArrayNumber] = digitalRead(ButtonBankSelect);//These setup the states of the buttons  
unsigned long trigTimer = 0;

if ((trigTimer \> 0) && (millis() - trigTimer \> 20))  
{  
digitalWrite(TRIG, LOW); // Set trigger low after 20 msec  
trigTimer = 0;  
}

{if(buttonState == HIGH) {

```
looper = (looper+1);
BankPush1 = (BankPush1+1);
BankPush2 = (BankPush2+1);
BankPush3 = (BankPush3+1);
BankPush4 = (BankPush4+1);
BankPush5 = (BankPush5+1);
BankPush6 = (BankPush6+1);
ClockKeep = (ClockKeep+1);

digitalWrite(TRIG, HIGH);

```

trigTimer = millis();

```
digitalWrite(OUT1,Sequence [1+BankArrayShift1][BankPush1 + NewKnobValue1] || (Fill1));
digitalWrite(OUT2,Sequence [2+BankArrayShift2][BankPush2 + NewKnobValue2] || (Fill2));
digitalWrite(OUT3,Sequence [3+BankArrayShift3][BankPush3 + NewKnobValue3] || (Fill3));
digitalWrite(OUT4,Sequence [7+BankArrayShift4][BankPush4 + NewKnobValue4] || (Fill4));
digitalWrite(OUT5,Sequence [8+BankArrayShift5][BankPush5 + NewKnobValue5] || (Fill5));
digitalWrite(OUT6,Sequence [9+BankArrayShift6][BankPush6 + NewKnobValue6] || (Fill6));
delay(10); // 10 ?
digitalWrite(OUT1,LOW);
digitalWrite(OUT2,LOW);
digitalWrite(OUT3,LOW);
digitalWrite(OUT4,LOW);
digitalWrite(OUT5,LOW);
digitalWrite(OUT6,LOW);
buttonState = LOW;

```

}  
else  
{  
looper = looper;  
ClockKeep = ClockKeep;  
}  
}

but it dont liek that at all…:

/home/lance/Documents/synth/BB/code\_b\_b/code\_b\_b.ino: In function ‘void loop()’:  
code\_b\_b:198:20: error: ‘TRIG’ was not declared in this scope  
digitalWrite(TRIG, LOW); // Set trigger low after 20 msec  
^~~~  
/home/lance/Documents/synth/BB/code\_b\_b/code\_b\_b.ino:198:20: note: suggested alternative: ‘TWIE’  
digitalWrite(TRIG, LOW); // Set trigger low after 20 msec  
^~~~  
TWIE  
code\_b\_b:213:18: error: ‘TRIG’ was not declared in this scope  
digitalWrite(TRIG, HIGH);  
^~~~  
/home/lance/Documents/synth/BB/code\_b\_b/code\_b\_b.ino:213:18: note: suggested alternative: ‘TWIE’  
digitalWrite(TRIG, HIGH);  
^~~~  
TWIE  
exit status 1  
‘TRIG’ was not declared in this scope

can you possibly be a little bit more precise as to where i stick it?

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [January 15, 2022, 5:24am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/13 "2022-01-15T05:24:03Z")

</div>

The code snippets I posted were from my MIDI to CV code, they won’t work here without modification. And they’re not to be just added, they’re to replace some of what’s there now. Instead of writing to TRIG you need to write to OUT1 through OUT6. Where there now is a 10 ms delay and then writing LOW to OUT1 through OUT6 is where you should instead put `trigTimer = millis();`. Also the declaration of trigTimer needs to be global — before, not inside, the loop() routine. I don’t have this module so I can’t write and test the code for you but that’s the gist of it.

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 15, 2022, 5:38am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/14 "2022-01-15T05:38:40Z")

</div>

Aha. I had thought as much but thought i could end up faffing for hours, so just asked first…

Hopefully ill have a chance to try it tonight, not in 2 weeks…

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 15, 2022, 10:16am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/15 "2022-01-15T10:16:24Z")

</div>

Ok I tried and had a look, but I really don’t have clue about coding so its really too much for me to have a crack at it. The digitalWrite in the BB has a heap of extras which I guess is the code for the programemd seuqnce (hence ‘Sequeunce’ in there)…

I’m suire for coders your instructions are sufficient and this task is trivial, but for me, that depth of instruction is kind of like saying to an analog newbie ‘make a basic op amp inverting mixer with trimpots for the required DC offset then just invert it again to get the signal within range.’

That, I can do no worries. This. Nup…

If anyone can help me out that would be great.  
in the meantime I’m just going to get the basic hardare wokring again and think about doing this the analog way BUUUUT I’d rather do it with program if pssible becasue that just seems more sensible…

IF anyone can help, I’d also wonder if its possible to make the gate legnth adjustable. I’d swap out the shift pot for gate length OR happily add a third pot.

cheers,

Lance

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 15, 2022, 11:31am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/16 "2022-01-15T11:31:20Z")

</div>

you kniow what. after all my stress, i think im fine.

ive got a pretty edge use case here wher i am driving high power LEDs for mega flashing light action, and when I benched it last time the pwoerLED was really dim, which I had interpreted as a really shprt trigger pulse.

But i just used a new arduino (the last one fired ) it is now totally usable for my case… I wonder if the old one was on its way out and I didnt realise it before…

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [January 15, 2022, 11:51am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/17 "2022-01-15T11:51:58Z")

</div>

[![](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/3X/a/8/a840b8b581863a15be596ffde41cf537a0c91736.jpeg "bench test, LMNC Big Button for Photosynthesis, MonaFoma 2022") ](https://www.youtube.com/watch?v=YkM7TixbrlM)

Bench test…

The black tube with yellow tape is actually a light sensor driving a BMC FM drum standalone. Normal people would just use a cable…

---

<div class="post-metadata">

**Author:** ![Cyclic](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Cyclic](https://lookmumnocomputer.discourse.group/u/Cyclic)\
**Post date:** [February 6, 2022, 10:23am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/18 "2022-02-06T10:23:10Z")

</div>

Ok. So I’m opening this topic up again with a Backflip. …

The gate **is** too short. I need to sort something out one way or another…

This is a video of our performance last weekend. The LED array (dubbed the do-deca-LED because theres 12 of them) is functioanlly split in two halves. The Right half from this view is a simple clock divider, the left half is the Big Button. As you can see the BB is blown away in terms of brightness to the point where its not relly functionaing as intended without a ton of faff. In the end, after making whats a pretty awesome light machine, I only really used half of it…

[![](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/3X/2/7/27ade75dfe52cfeada6fc938e01477d589cc00c0.jpeg "Photosynthesis at MOFO 2022") ](https://www.youtube.com/watch?v=QTxF6mKJ5gw)

I’d really like some help to modify the code. Ideally in a way that the gate length can be either switched short/long or analog controlled with a pot, but at the least, set to a greater value without slowing down the code.

I’m happy to learn a bit and do the work but I need, at the least, some advice to get started. I am not trying to become a coder here, just smoosh other peoples code together in a way that works for me.

cheers,

Lance

---

<div class="post-metadata">

**Author:** ![Caustic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/caustic/32/15588_2.png) [@Caustic](https://lookmumnocomputer.discourse.group/u/Caustic)\
**Post date:** [February 7, 2022, 11:56am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/19 "2022-02-07T11:56:20Z")

</div>

Hey, I’m in the middle of a big move so I don’t have my computer in front of me, but can you post the code you are currently using in it’s present form? Should be as simple as increasing the wait times between the low and highs.

---

<div class="post-metadata">

**Author:** ![eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@eric](https://lookmumnocomputer.discourse.group/u/eric)\
**Post date:** [February 7, 2022, 11:59am UTC](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461/20 "2022-02-07T11:59:52Z")

</div>

The original code does a delay(10) in the main loop, inceasing it, while increasing the length, makes the user interface slugish…

[Next page](https://lookmumnocomputer.discourse.group/t/big-button-gate-length/4461.md?page=2)
