Whatever it is that you are trying to do, these general recommendations always apply:
- Break your program into manageable functions that just do one thing. Test the functions individually. When they work, chain them together. Just don't throw everything into the
loop()and hope for the best. - Fix that indentation, add some blank lines to separate different sections, bring some order into the code. The compiler may not care, but you will, and people trying to help you will, too.