Arduino dies

Hi there, I have an arduino uno board with this software on it

void setup()
{
  Serial.begin(9600);
  pinMode(11, OUTPUT);
  pinMode(7, OUTPUT);
}
void(* resetFunc) (void) = 0; // functie reset

void loop()
{
  int senzor1 = analogRead(A0);
  int senzor2 = analogRead(A5);

  int senzormod = (senzor2 - 0);
  int tol = 15;


  if (senzor1 < 400 )
  {

    digitalWrite(11, LOW);
    digitalWrite(7, LOW);
    delay(3000);
  }

  if (senzormod < 400 )
  {

    digitalWrite(11, LOW);
    digitalWrite(7, LOW);
    delay(3000);
  }

  else

    if ((abs(senzor1 - senzormod) <= tol || abs(senzormod - senzor1 ) <= tol))
    {
   
      digitalWrite(11, LOW);
      digitalWrite(7, LOW);
      delay(2000);

    }

    else

      //if((abs(senzor1 - senzormod) <= tol || abs(senzormod - senzor1 ) <= tol))
    {

      if (senzor1 > senzormod)
      {
        digitalWrite(11, LOW);
        digitalWrite(7, LOW);
        digitalWrite(11, HIGH);
        //  Serial.println("S1 > S2 ");
        //  Serial.print(int(senzor1 - senzormod));
        delay(3000);

        //Serial.print("Diferenta > ");
        //Serial.println(int(senzor1 - senzormod));
        

      }

      if (senzormod > senzor1)

      {
        digitalWrite(7, LOW);
        digitalWrite(11, LOW);
        digitalWrite(7, HIGH);
        //  Serial.println("S2 > S1 ");
        //  Serial.print(int(senzor1 - senzormod));
        delay(3000);
        
        //Serial.print("Diferenta > ");
        //Serial.println(int(senzor1 - senzormod));
        
      }
    }
}

Problem is that arduino after a while dies, practical does not respond anymore to the input voltage.

Any ideas would be appreciated

HI,
What is the program supposed to do, what are its inputs and outputs.
What do you mean by "dies"

Tom.... :slight_smile:

Hi there, program measure 2 sensor's (voltage) A0 and A5 it's for a solar tracker, the output pins correspond to left or right.

The output pin goes to 2 transitor's and open a gate.

After a while, 2-3 hours of running arduino stops to work does not move left or right (Dies).

How is your Arduino powered ?

How is the thing that is connected to the transistors powered ?

When the Arduino stops how do you get it working again ?

Make a pencil drawing showing all your connections and components and post a photo of the drawing.

...R

Hi,

 int senzormod = (senzor2 - 0);

Not sure why you did this, as you do not use senzor2 again in the sketch.

What do the Serial.print tell you monitor?
Does resetting the controller fix the problem?

Please as Robin2 requests a circuit diiagram, plus a picture of your project so we can see how your sensors are configured.

Hope to help .....Tom.... :slight_smile: