# How to change patterns with digital input

**URL:** <https://forum.electromage.com/t/how-to-change-patterns-with-digital-input/4765>\
**Category:** Uncategorized\
**Created:** [September 20, 2026, 1:54am UTC](https://forum.electromage.com/t/how-to-change-patterns-with-digital-input/4765 "2026-09-20T01:54:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![airtap](https://forum.electromage.com/user_avatar/forum.electromage.com/airtap/32/4142_2.png) [@airtap](https://forum.electromage.com/u/airtap)\
**Post date:** [September 20, 2026, 1:54am UTC](https://forum.electromage.com/t/how-to-change-patterns-with-digital-input/4765/1 "2026-09-20T01:54:14Z")

</div>

Hello. I have a pixelblaze 3.6 driving an 8x8 matrix. I am trying to use the digital inputs to control a pattern change, eg. I25 invokes “pattern 1” and I26 “pattern 2”. I will control the inputs by turning each on and off in a way that they both don’t come on at the same time. I have tried a few methods mentioned in the forum, but am having trouble with the code. I wonder if someone could write an example as outlined above so I could paste it in and learn from the code what to do. This would be much appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![airtap](https://forum.electromage.com/user_avatar/forum.electromage.com/airtap/32/4142_2.png) [@airtap](https://forum.electromage.com/u/airtap)\
**Post date:** [October 13, 2026, 8:25pm UTC](https://forum.electromage.com/t/how-to-change-patterns-with-digital-input/4765/2 "2026-10-13T20:25:58Z")

</div>

Can anyone help with this?

---

<div class="post-metadata">

**Author:** ![danielgarcia](https://forum.electromage.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@danielgarcia](https://forum.electromage.com/u/danielgarcia)\
**Post date:** [November 12, 2026, 12:14am UTC](https://forum.electromage.com/t/how-to-change-patterns-with-digital-input/4765/3 "2026-11-12T00:14:49Z")

</div>

One gotcha: if a pattern switches away with setPattern(), it stops running, so it can’t keep watching the inputs. Either put the same input check in every pattern, or use one pattern with two modes. Example:

var mode = 0;

export function beforeRender(delta) {

if (digitalRead(25)) mode = 0;

else if (digitalRead(26)) mode = 1;

}

export function render(index) {

if (mode == 0) { / _pattern 1 pixel code_ / }

else { / _pattern 2 pixel code_ / }

}

Add pinMode(25, INPUT) etc. if your firmware requires it.
