Welcome, and congratulations, most new members don't master the code tags until reminded. However, you're describing a system. The system includes hardware, so we'll need to see how it's wired; for that, a schematic would be very useful, a fritzing diagram less so. Please label all pins, power sources, modules, etc. in the schematic.
Thanks, and again, welcome!
Oh, and the problem is very likely in the code you didn't post, so complete code, please. In the IDE, press ctrl-T to format the code, then shft-ctrl-C to copy it for the forum. Paste it in a new message, don't update the first one.
For further info, please refer to
Finally, please move your post to Programming Questions, or Project Guidance, or some other section, as it's not about the IDE2.x.
Thanks, and sorry for the 'rules', we kinda live and die by them around here!