Inconsistent behavior

We can't see your wiring or your code.

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

How to make a schematic that you can post.

edit: added link to schematic tutorial