LED pattern stuck every time I release latching switch

Hi, I've recently put together a setup with a tactile/momentary switch, latching switch, and Arduino Nano using an altered version of the All Effects sketch from Tweaking4All's Fastled/Neopixels page. However, although the tactile switch works perfectly in toggling from one sketch to another, the latching switch (spst) has a peculiar tendency to pause the effect when I power it off (it powers on fine). Of note, the power LED on the Arduino itself shows on and off when I push and release the latching switch, but when in the off position it pauses the sketch, instead of shutting off completely. I was told by a friend this shouldn't be happening since the VIN input on the Arduino shouldn't be affected by code. Hopefully someone here can help me, as it would not be very product friendly to have to manually unplug the adapter from the DC jack every time you want to power off :slight_smile: Thanks in advance!

Here is a "schematic" of my setup to the best of my knowledge:


Here's the code (I'm assuming too large for this forum, so I posted on Pastebin):

All effects sketch with tactile button and latching switch

Any help is much appreciated! I'm still a beginner, so forgive me for any stupidity :slight_smile:

If you post your code as described in the how to use this forum sticky, more members will read it. Few will download it first.

The Arduino is sending data to the addressable LED strip. Turn off the Arduino and the data stops. And the LED strip shows whatever data was last sent.

You need to turn off the LEDs (all black) in the sketch before turning off the Arduino.

I apologize; I checked out the forum rules and I should have posted the code right here. I initially didn’t because it was very long and recently I posted on the Fastled Reddit page and was told not to post large amounts of code in my question; that I was to use Pastebin. Anyway, I will remember for next time; thanks for the tip.

It worked! I just moved the switch to the 5v on the strip itself and it works perfectly. Thank you very much; the logic is awesome. I hope others benefit from this.