Arduino Keep restart coding

Hye guys…I have problem with my arduino…I use my arduino one servo motor, 2 gas sensor, 1 LM35 and 4 relay module…The problem is after the arduino running at the loop function then it keep restart to setup function… i need the code to running in loop function…can anyone help me please…thank you

final_coding.ino (2.48 KB)

Wild guess is that it's drawing too much current and resetting the board. If you're powering (as opposed to controlling) the servo and the relays from the Arduino that's quite likely.

Post circuit schematic...

For all the sensor and servo I use other power source. It still efffect the arduino board?

husnulasyraf:
For all the sensor and servo I use other power source. It still efffect the arduino board?

manor_royal:
Post circuit schematic...

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Code and circuit will help us to advise you on how to fix your problem.
Please include what sort of power supplies you are using, for Aduino, what type, and for the servos, two gas units and relay PCB.
Links to data/specs on the servos, relay PCB and especially the gas sensors.

Thanks.. Tom... :slight_smile:

Please reformat your code for correct indentation and re-post. It's too hard to read at the moment and follow the logic. There doesn't appear to be anything too wild that would cause memory issues, so most likely a circuit issue as per other posters.

Sory for late…Here I attached my circuit

That circuit doesn’t show any connection to the Arduino Gnd pins.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Hi,
OPs “circuit”
00a2f62b937494218d9a574ffafcb6465a9e9987.png
Unfortunately this not a circuit diagram, it shows no component information.
Where is your gnd of the UNO connected to the gnd of the servo 5V 2A suppy.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Not a fritzy.

Thanks… Tom… :slight_smile:

Hi,
Did you write this code in stages so you could get each feature working before moving to the next stage?

Tom... :slight_smile: