 void setup()
 {
 
+  // start serial
+  Serial.begin (38400);
+  Serial.println("TV controller Starting");
+  delay(20);
+
+  // Timer start
+  startMills = millis();
+
   // lcd
   lcd.init();
   lcd.backlight();
   lcd.clear();
-  lcd.createChar(1, termometru);
-  lcd.setCursor(0, 0);
-  lcd.write(1);
-  // lcd
-
-  Serial.begin (38400);
-  Serial.println("TV controller Starting");
-  delay(20);
-
-  irrecv.enableIRIn(); // Start the receiver
-
-  startMills = millis();
+
+  // ir
+  irrecv.enableIRIn();
 
   // pin mode
-
   pinMode(SETUP_IN_PIN, INPUT_PULLUP);
-  pinMode(ENTER_IN_PIN, INPUT_PULLUP);
+  pinMode(WRK_MODE_IN_PIN, INPUT_PULLUP);
+  /*
   pinMode(DN_IN_PIN, INPUT_PULLUP);
   pinMode(UP_IN_PIN, INPUT_PULLUP);
+  */
   pinMode(PIR_IN_PIN, INPUT_PULLUP);
 
+  // buzzer
   pinMode(BZ_OU_PIN, OUTPUT);
   digitalWrite(BZ_OU_PIN, HIGH);
 
-
-  // temp
+  // read pin status
+  setUpStatus   = digitalRead(SETUP_IN_PIN);
+  wrkModeStatus = digitalRead(WRK_MODE_IN_PIN);
+
+  // initialize eeprom  
+  long magic;
+  eeprom_read(magic, magic);
+  if ((magic != magic_number) || ( setUpStatus == 0 ) {
+     run_initialise_setup();
+  }
+
+
+  // temp sensor
   sensors.begin();
   if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
   sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);

    Serial.println("Failed to read from sensor!");
    return;
  }
  // temp

}


void loop()
{
  /*
   *
    pinMode(SETUP_IN_PIN, INPUT_PULLUP);
    pinMode(ENTER_IN_PIN, INPUT_PULLUP);
    pinMode(DN_IN_PIN, INPUT_PULLUP);
    pinMode(UP_IN_PIN, INPUT_PULLUP);
    pinMode(PIR_IN_PIN, INPUT_PULLUP);
   *
   */
  /*
    int x = digitalRead(ENTER_IN_PIN);
    Serial.println(x);
    //getdalastemp();
    //Serial.println(tempCinside);
    delay(1000);
  */

  decode_results results;

  if (irrecv.decode(&results)) {
    dumpInfo(&results);

  }

}



#include <Wire.h>
#include <OneWire.h>
