   Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
 
   nfc.SAMConfig(); // configure board to read RFID tags
-
+  
   lcd.setCursor(0,1);
   lcd.print("NFC OK");
-  delay(1000);
-  }
-
-void menu()
-{
-  lcd.clear();
-  lcd.print("Menu");
-  lcd.setCursor(0,1);
-  lcd.print(oldPosition / 4);
+  //delay(1000);
+  lcd.clear();
+  }
+
+
+
+void encoder()
+{
+  int newPosition = myEnc.read();
+  if ((newPosition != oldPosition) )
+  {
+    
+     
+    oldPosition = newPosition;
+    if(oldPosition < 0)
+    {
+       myEnc.write(255);
+    }
+    if(oldPosition > 255)
+    {
+       myEnc.write(0);
+    }
+    Serial.println(newPosition / 4);
+    cycleMenu = (abs(newPosition) / 4) / MENUELEMENTS;
+    lcd.clear();
+  }
+}
+
+void loop(void)
+{
+ byte relativePosition = (abs(oldPosition) / 4) - (cycleMenu * MENUELEMENTS);
+  lcd.setCursor(0,0);
+  
+    
+  lcd.print(menuStrings[relativePosition][0]);
+  lcd.setCursor(0,1);
+  lcd.print(menuStrings[relativePosition][1]);
   encoder();
-  delay(50);
+  
   if (!digitalRead(encButton))
    {
     Serial.println("BOUTON !");
-    buzy = true;
+    if (relativePosition == 0)
+      nfc_read();
+    else if (relativePosition == 1)
+    {
+      lcd.clear();
+      lcd.print(" not finished");
+      delay(1000);
+    }
    }
-    //lcd.print("Waiting card");
-}
-
-void encoder()
-{
-  long newPosition = myEnc.read();
-  if (newPosition != oldPosition)
-  {
-    oldPosition = newPosition;
-    Serial.println(newPosition / 4);
-  }
-}
-
-void loop(void)
-{
- if (buzy == true)
- {
-  nfc_read();
- }
- else
- {
-  menu();
- }
 }
 
 void nfc_read()

            }
            // Dump the raw data
            nfc.PrintHexChar(data, 16);
            buzy = false;
            if (currentblock == 24)
            {
              currentBalance = (data[6] * 256) + data[7];

#include <LiquidCrystal.h>
#include <Encoder.h>

#define MENUELEMENTS 2

PN532_I2C pn532_i2c(Wire);
PN532 nfc(pn532_i2c);

