When I uploaded the firmware into the arduino and run the program first time, it runs properly without any error. But after the program executes the second case of the flat sequence it stops because of the logic provided. but in second when i run it it start showing error. why is this happening please help me. It's really urgent.