// C++ code
//
#include <LiquidCrystal.h>
int valbutton;
int valbutton1;
int valbutton2;
int valbutton3;
int valbutton4;
int valbutton5;
int indiceLong = 1;
int LA = 0; // compteur de langueur
int L1 = 0; // longueur fixe n1
int L2 = 0; // longueur fixe n2
int L3 = 0; // longueur fixe n3
int L4 = 0; // longueur fixe n4
int L5 = 0; // longueur fixe n5
int L6 = 0; // longueur fixe n6
const int button = 43 ; // input
const int button1 = 53 ; // input
const int button2 = 51 ; // input
const int button3 = 49 ; // input
const int button4 = 47 ; // input
const int button5 = 45 ; // input
const int LedPin = 13 ; //output
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); // output ecran LCD 2x12
void setup()
{
pinMode(button, INPUT);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(button4, INPUT);
pinMode(button5, INPUT);
pinMode(LedPin, OUTPUT);
lcd.begin(16, 2);
lcd.print("L = N=");
}
void loop(){
valbutton = digitalRead (button);
valbutton1 = digitalRead (button1);
valbutton2 = digitalRead (button2);
valbutton3 = digitalRead (button3);
valbutton4 = digitalRead (button4);
valbutton5 = digitalRead (button5);
if (valbutton == HIGH)
{
digitalWrite(LedPin,LOW);
lcd.setCursor(1,0);
lcd.print(indiceLong);
//delay(100); // Wait for 100 millisecond(s)
if (valbutton1 == LOW && indiceLong < 7)
{
//lcd.setCursor(1,0);
//lcd.print(" ");
lcd.setCursor(1,0);
lcd.print(indiceLong);
//lcd.setBacklight(1);
delay(100); // Wait for 100 millisecond(s)
indiceLong++;
delay(100);
//lcd.setCursor(1,0);
//lcd.print(" ");
//delay(100); // Wait for 100 millisecond(s)
}
if (indiceLong > 6)
{
indiceLong = 1;
lcd.setCursor(1,0);
lcd.print(" ");
delay(100); // Wait for 100 millisecond(s)
}
else
{
lcd.setCursor(7,0);
lcd.print(LA);
//lcd.setBacklight(1);
delay(100); // Wait for 100 millisecond(s)
if (valbutton3 == LOW)
{
LA++;
lcd.setCursor(7,0);
lcd.print(" ");
//charger les valeurs de L
if (indiceLong == 1){L1 = LA;}
if (indiceLong == 2){L2 = LA;}
if (indiceLong == 3){L3 = LA;}
if (indiceLong == 4){L4 = LA;}
if (indiceLong == 5){L5 = LA;}
if (indiceLong == 6){L6 = LA;}
else {}
delay(100);}
else if (valbutton2 == LOW)
{
LA--;
lcd.setCursor(7,0);
lcd.print(" ");
//charger les valeurs de L
if (indiceLong == 1){L1 = LA;}
if (indiceLong == 2){L2 = LA;}
if (indiceLong == 3){L3 = LA;}
if (indiceLong == 4){L4 = LA;}
if (indiceLong == 5){L5 = LA;}
if (indiceLong == 6){L6 = LA;}
else {}
delay(100);}
else {
lcd.setCursor(7,1);
lcd.print(L1);
//lcd.setBacklight(1);
lcd.setCursor(1,1);
lcd.print(L5);
//lcd.setBacklight(1);
delay(50); // Wait for 100 millisecond(s)
}
}
}
else
{
digitalWrite(LedPin,HIGH);
lcd.setCursor(0,0);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
//lcd.setBacklight(1);
lcd.setCursor(5,1);
lcd.print(L5);
// lcd.setBacklight(1);
}
}