title: Arduino not working after a while
body: <p>My arduino stops working after a while.
  Here's my code:</p>
  
  <pre><code>//Pin.h is my header file
  
  #ifndef Pin_h
  #define Pin_h
  
  class Pin{
    public:
     Pin(byte pin);
     void on();//turn the LED on
     void off();//turn the LED off
     void input();//input PIN
     void output();//output PIN
  
    private:
      byte _pin;    
  };
  
  #endif
  
  
  //Pin.cpp is my members definitions
  #include "Arduino.h"
  #include "Pin.h"
  
  Pin::Pin(byte pin){//default constructor
     this-&gt;_pin = pin;
  }
  
  void Pin::input(){
    pinMode(this-&gt;_pin, INPUT);
  }
  
  void Pin::output(){
    pinMode(this-&gt;_pin, OUTPUT);
  }
  
  void Pin::on(){
    digitalWrite(this-&gt;_pin, 1);//1 is equal to HIGH
  }
  
  void Pin::off(){
    digitalWrite(this-&gt;_pin, 0);//0 is equal to LOW
  }
  
  
  //this is my main code .ino
  #include "Pin.h"
  
  Pin LED[3] = {//array of objects
   Pin(11),
   Pin(12),
   Pin(13)
  };
  
  const byte MAX = sizeof(LED);
  
  //MAIN PROGRAM----------------------------------------------------------------------------------
  void setup() {
    for(int i = 0; i &lt; MAX; i++){
        LED[i].output();
    }//end for loop initialize LED as output
  }//end setup
  
  int i = 0;
  
  void loop() {
    for(i = 0; i &lt; 3; i++){
      LED[i].on();
      delay(1000);
    }
  
    for(i = 3; i &gt;= 0; i--){
      LED[i].off();
      delay(1000);
    }
  
  }//end loop
  //see class definition at Pin.h
  //see class members at Pin.cpp
  </code></pre>
  
  <p>My arduino stops working when I use two for loops inside the void loop function, but if I use this code below in my main, it works fine. Why does my arduino stop after a while when using for loops?</p>
  
  <pre><code>void loop() {
    LED[0].on();
    delay(1000);
  
    LED[1].on();
    delay(1000);
  
    LED[2].on();
    delay(1000);
  
    LED[2].off();
    delay(1000);
  
    LED[1].off();
    delay(1000);
  
    LED[0].off();
    delay(1000);  
  }//end loop
  </code></pre>