Help with project

Currently working on a project to replace a control panel for a machine. The machine has 5 sensors and a button to run the selected mode, the LCD screen shows currently selected mode and has buttons I use to switch between modes. The 2 moving parts are controlled by switching relays. The arduino is a model Mega 2560 powered by external power of 9V 1000 mA. The memory during the check didn’t drop below 7000. The program seems to work fine but after a while it starts doing random stuff and resetting.

Code of program: control panel of a project by m3tam4n · Pull Request #1 · m3tam4n/pultas · GitHub

Edit: the relays are missing from the schematic since i am using a board with 2 relays (model SRD-05VDC-SL-C)

pultas.ino (4.6 KB)

Please post your code, inside code tags. Please also post a schematic.

Added the stuff.

Some debug prints might help you track down the problem.

I guess we can leave the code tags until later.

I tried the debug. And data seems normal, however after some cycles instead of step 4 i throws out stuff like &&#% and starts to do weird stuff. The code seems to work fine at least for a while so i don't know what else it could be.

Try adding some decoupling.

Added the decoupling to the relay control. Seems a bit more stable but it still seems to have some problems.

How about adding a schematic that is actually readable. I can't see the relay on that one. Have you got a kick back diode across the really coil?