Rotary Encoder/LCD with SD memory

I am working with LCD menu using Rotary encoder. everything is working fine until I push the button of the rotary encoder it is resetting the program instead of selecting the menu or submenu. if I comment the saving line everything is working fine :confused:
I looked everywhere but I wasn't successful to find a solution.

I looked everywhere but I wasn't successful to find a solution.

So continue looking as we cannot help you if you're still hiding your code and wiring.

Sounds like you have the push switch wired so that it is a dead short of the power when pushed. But without a schematic that is just a guess. One side of the switch to ground and the other side to a digital input set to pinMode INPUT_PULLUP is the standard way to wire a switch.

But without a schematic that is just a guess.

How about that schematic, please?

Here's the code it is working fine when Save(10); is commented

So what happens when it's not commented?

How to solve the INPUT_PULLUP problem because I think it is my problem.

Wire the switch as shown in the posted image. Change the pinMode to INPUT_PULLUP. Change the logic in the program to the switch being active LOW (LOW when pressed).

More members will see your code if posted properly. Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Post a photo of your hand drawn schematic.

Here's the handwritten schematic attached
So the rotary encoder is moving through the menu but when I click to select so I can go to the sub menu it restart to the main screen "Weclome()" function instead of going to sub menu. It is working fine if I just comment the line Save(10);
So the PUSHB is the one causing the conflict but only when SD is added.
I tried both program separately and working fine too.

Thanks,

I did narrow it down to this line but no luck what might be the problem.
myFile = SD.open("test7.txt", FILE_WRITE);
So the question is can I save my data without SD.open() command line?

groundFungus:
Sounds like you have the push switch wired so that it is a dead short of the power when pushed. But without a schematic that is just a guess. One side of the switch to ground and the other side to a digital input set to pinMode INPUT_PULLUP is the standard way to wire a switch.

@groundFungus, I did place the schematics should I still wire the switch as described above?
I am a little bit confused should I connect as following
A10 <-> SW <-> R1 <-> 5V and
GND <-> SW <-> C1 <-> A10 ??

If you set the pinMode to INPUT_PULLUP R1 is not used. C1 goes across (in parallel with) the switch and is optional. If you are not sure, just leave it off. So, one terminal of the switch goes to the digital input and the other terminal goes to ground. Remember that the logic is: switch not pressed, input reads HIGH. Switch pressed, input reads LOW.