Register or Record or Write Temporary Data to Operate

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int value = 4;
int pin = 24;

int LEDState=0;

const byte  ValuePluss = 10;    // for increment
const byte  ValueMinus = 11;    // for decrement
const byte  buttonPin1 = 22;    // the pin that the pushbutton is attached to
const byte  buttonPin2 = 23;
const byte  buttonPin3 = 24;    
const byte  buttonPin4 = 25;
const byte  buttonPin5 = 26;    
const byte  buttonPin6 = 27;

const byte  ledPinA = 4;       // the pin that the LED is attached to
const byte  ledPinB = 5;
const byte  ledPinC = 6;       // the pin that the LED is attached to
const byte  ledPinD = 7;
void setup() {
  // put your setup code here, to run once:
   lcd.init();
   lcd.backlight();

   pinMode(ValuePluss, INPUT_PULLUP);
   pinMode(ValueMinus, INPUT_PULLUP);
   pinMode(buttonPin1, INPUT_PULLUP);
   pinMode(buttonPin2, INPUT_PULLUP);
   pinMode(buttonPin3, INPUT_PULLUP);
   pinMode(buttonPin4, INPUT_PULLUP);
   pinMode(buttonPin5, INPUT_PULLUP);
   pinMode(buttonPin6, INPUT_PULLUP);

   pinMode(ledPinA, OUTPUT);
   digitalWrite(ledPinA, LOW);
   pinMode(ledPinB, OUTPUT);
   digitalWrite(ledPinB, LOW);
   pinMode(ledPinC, OUTPUT);
   digitalWrite(ledPinC, LOW);
   pinMode(ledPinD, OUTPUT);
   digitalWrite(ledPinD, LOW);

   lcd.setCursor(7, 0);
   lcd.print("Pin-");
   lcd.setCursor(11, 0);
   lcd.print(pin);
   
   lcd.setCursor(7, 1);
   lcd.print("val-");
   lcd.setCursor(11, 1);
   lcd.print(value);

}

void loop() {
  // put your main code here, to run repeatedly:

     if(!digitalRead(22))
        {
         if(value<7)
         {
            value=value+1;
         }
         else
         {
            value=4;
         }
          delay(100);
          lcd.setCursor(7, 1);
          lcd.print("val-");
          lcd.setCursor(11, 1);
          lcd.print(" ");
          lcd.setCursor(11, 1);
          lcd.print(value);
        }

        if(!digitalRead(23))
        {
         if(value>4)
         {
            value=value-1;
         }
         else
         {
            value=7;
         }
          delay(100);
          lcd.setCursor(7, 1);
          lcd.print("val-");
          lcd.setCursor(11, 1);
          lcd.print(" ");
          lcd.setCursor(11, 1);
          lcd.print(value);
        }

      if(digitalRead(24)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("24");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }


      if(digitalRead(25)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("25");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }

      if(digitalRead(26)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("26");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }

      if(digitalRead(27)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("27");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }

      
}
      


As per code above, I am using a MEGA board with few Push buttons and LEDs

Here I am using a counter type code to count from 4 to 7 which are also the pin number for LEDs basically

I have 4 other push buttons at pin 24 25 26 27 just to operate LEDs at 4 5 6 7
It can be done easily by giving command within the code

But now as the thread name is here
I want to make changes in the matching of Push button with LEDs randomly without use of code

Suppose our basic match from code for push button to LEDs are
24 - 4
25 - 5
26 - 6
27 - 7

Now we want to make a random match from our designed system be like
24 - 6
25 - 4
26 - 5
27 - 7

or

24 - 7
25 - 5
26 - 4
27 - 6

and so on . . .

This should not be done by using a laptop or cellphone or simply the code via IDEs

In simple sentence I want to make a system which can register a a data itself with use of some input push buttons and to operate as per data entered until the Arduino Power gets OFF

For data manipulation purpose I am using 4-7 counter here for basics
(where a 4 simple push button can also be added or a keypad can also be there in advance case)

I don't have a single idea about such type of concept
that

if it really don't exists
and I am thinking and doing silly things wrong way

or

It can be done with some advanced kind of concept or hardware add-on
and I am heading right way

Please guide me !!

May be I am not able to explain properly above so please ask but help me out !!

Just today this idea came in mind

Thanks !!!!!!!!!!!!

Create the random associations when the Arduino is reset. Left to its own devices the Arduino will generate the same "random" sequence every time that it is turned on but there are ways round this by using the randomSeed() function

  • use a reading from a floating analigue input as the seed for the randomSeed() function
  • use a button press to start the random association process and use the millis() or micros() value at that time as the seed for the randomSeed() function

O I see

But Sir its a complete new thing for me
so not getting a single point here

Can you guide me with some kind of link or something which I can understand Please

Sir got this from reference

long randNumber;

void setup() {
  Serial.begin(9600);
  randomSeed(analogRead(0));
}

void loop() {
  randNumber = random(300);
  Serial.println(randNumber);
  delay(50);
}

what this 300 is showing ??

is it the line from where we want to start ???

That sketch will generate a series of random numbers between 0 and 299

Try this sketch as a starting point to what you want to do. Obviously change the input pin to suit your hardware and wire the button to take the pin LOW when pressed

const byte startPin = A3;

void setup()
{
    Serial.begin(115200);
    pinMode(startPin, INPUT_PULLUP);
    Serial.println("Press the button on pin A3 to start");

    while (digitalRead(startPin) == HIGH)  //wait for the button to be pressed
    {
        //do nothing
    }
    randomSeed(micros());
    int aRandomNumber = random(0,4);   //a random number between 0 and 3
    Serial.print("the random number is ");
    Serial.println(aRandomNumber);
}

void loop()
{
}

Every time you reset the Arduino you will get a number between 0 and 3 which we can use to set up the relationships between pushbuttons and LEDs, but get this working first

Ok le me go through this in WOKWI first

Yes sir sometimes 3 or sometime 2 it displays

Now what's next ??

It should display a number between 0 and 3 but could display the same number several times in succession. It is, after all, random

So, you have a random number between 0 and 3 giving 4 possibilities so you could write code like this in loop() once you detect a button press that should turn on an LED

if (aRandomNumber == 0)
  {
    //do this
  }
else if (aRandomNumber == 1)
  {
    //do this
  }

//etc, etc

Where I have written `//do this' you could enter the code to respond to your button inputs to cause different LEDs to be turned on and make the actions different for each value 0 to 3

This is not a sensible way to do what you want as there are neater ways but try this way first

Ya it is displaying a continuous 3 after every reset

So only the section under

if (aRandomNumber == 3)

is working only and not rest

what I need to do ??

Any changes in my basic coding ??

Post your full sketch

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int value = 4;
int pin = 24;

int LEDState=0;

const byte  ValuePluss = 10;    // for increment
const byte  ValueMinus = 11;    // for decrement
const byte  buttonPin1 = 22;    // the pin that the pushbutton is attached to
const byte  buttonPin2 = 23;
const byte  buttonPin3 = 24;    
const byte  buttonPin4 = 25;
const byte  buttonPin5 = 26;    
const byte  buttonPin6 = 27;

const byte  ledPinA = 4;       // the pin that the LED is attached to
const byte  ledPinB = 5;
const byte  ledPinC = 6;       // the pin that the LED is attached to
const byte  ledPinD = 7;
long randNumber;
const byte startPin = A3;
int aRandomNumber = random(0,4);
void setup() {
  // put your setup code here, to run once:
   lcd.init();
   lcd.backlight();

   pinMode(ValuePluss, INPUT_PULLUP);
   pinMode(ValueMinus, INPUT_PULLUP);
   pinMode(buttonPin1, INPUT_PULLUP);
   pinMode(buttonPin2, INPUT_PULLUP);
   pinMode(buttonPin3, INPUT_PULLUP);
   pinMode(buttonPin4, INPUT_PULLUP);
   pinMode(buttonPin5, INPUT_PULLUP);
   pinMode(buttonPin6, INPUT_PULLUP);

   pinMode(ledPinA, OUTPUT);
   digitalWrite(ledPinA, LOW);
   pinMode(ledPinB, OUTPUT);
   digitalWrite(ledPinB, LOW);
   pinMode(ledPinC, OUTPUT);
   digitalWrite(ledPinC, LOW);
   pinMode(ledPinD, OUTPUT);
   digitalWrite(ledPinD, LOW);

   lcd.setCursor(7, 0);
   lcd.print("Pin-");
   lcd.setCursor(11, 0);
   lcd.print(pin);
   
   lcd.setCursor(7, 1);
   lcd.print("val-");
   lcd.setCursor(11, 1);
   lcd.print(value);


   randomSeed(analogRead(0));

   pinMode(startPin, INPUT_PULLUP);
   lcd.setCursor(0, 0);
   lcd.print("Press");

   while (digitalRead(startPin) == HIGH)  //wait for the button to be pressed
    {
        //do nothing
    }
    randomSeed(micros());
       //a random number between 0 and 3
    // Serial.print("the random number is ");
    // Serial.println(aRandomNumber);
    lcd.setCursor(0, 1);
    lcd.print("numbr");
    lcd.setCursor(5, 1);
    lcd.print(aRandomNumber);

}

void loop() {
  // put your main code here, to run repeatedly:

      // randNumber = random(68);
      // // Serial.println(randNumber);
      // delay(50);

     if(!digitalRead(22))
        {
         if(value<7)
         {
            value=value+1;
         }
         else
         {
            value=4;
         }
          delay(100);
          lcd.setCursor(7, 1);
          lcd.print("val-");
          lcd.setCursor(11, 1);
          lcd.print(" ");
          lcd.setCursor(11, 1);
          lcd.print(value);
        }

        if(!digitalRead(23))
        {
         if(value>4)
         {
            value=value-1;
         }
         else
         {
            value=7;
         }
          delay(100);
          lcd.setCursor(7, 1);
          lcd.print("val-");
          lcd.setCursor(11, 1);
          lcd.print(" ");
          lcd.setCursor(11, 1);
          lcd.print(value);
        }
      
      if (aRandomNumber == 0)
      {

      if(digitalRead(24)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("24");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }


      }


      else if (aRandomNumber == 1)
      {
        //do this


      if(digitalRead(25)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("25");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }

      }

      else if (aRandomNumber == 2)
      {

      if(digitalRead(26)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("26");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }
      }

      else if (aRandomNumber == 3)
      {

      if(digitalRead(27)==LOW)
      {
        lcd.setCursor(11, 0);
        lcd.print("27");
        if(value==4)
        {
        digitalWrite(4, HIGH);
        }
        if(value==5)
        {
        digitalWrite(5, HIGH);
        }
        if(value==6)
        {
        digitalWrite(6, HIGH);
        }
        if(value==7)
        {
        digitalWrite(7, HIGH);
        }
      }
      else
      {
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        digitalWrite(6, LOW);
        digitalWrite(7, LOW);
      }
      }

}
      


You are calling the random() function only once and you are doing it before you call the randomSeed() function

Do you remember what I said earlier ?

That is why you get the number 3 every time

Compare that with my code from post #5 which waits for an unknown time for the user to press a button then uses the value of micros() with the randomSeed() function to start the random number generation at a different place each time the code is run, or as near as possible, and hence get a different random number

sir would you please help me with a very small code and the operation of sequence I need to perform ?

In this way I can steadily get the things clearly

Just a very small one with a single input Please :sleepy:

const byte startPin = A3;   //change this to suit your start button pin

void setup()
{
    Serial.begin(115200);
    pinMode(startPin, INPUT_PULLUP);
    Serial.println("Press the button on pin A3 to start");

    while (digitalRead(startPin) == HIGH)  //wait for the button to be pressed
    {
        //do nothing
    }
    randomSeed(micros());  //seed the random function depending on how long we waited for input
}

void loop()
{
    int aRandomNumber = random(0, 4);  //random number between 0 and 3
    if (aRandomNumber == 0)
    {
        Serial.println("got a 0");
    }
    else if (aRandomNumber == 1)
    {
        Serial.println("got a 1");
    }
    else if (aRandomNumber == 2)
    {
        Serial.println("got a 2");
    }
    else if (aRandomNumber == 3)
    {
        Serial.println("got a 3");
    }
    delay(1000);  //slow down the output so that we can read it
}

OK so this one is generating multiple instances from 0 to 3 . . !!

So now I have to enter data at a particular instance say '2' ???????

It sounds like it is working

Now you have to insert the code for what you want to happen at each case

ie, for case 0 it may be

if the user presses the button on pin A turn on LED 0
else if the user presses the button on pin B turn on LED 1
//etc

As I said previously, there is a much better way of doing this but get the clumsy way working first

1 Like

Ya basic is IMP anywhere

Ya I got the point as I've to use laptop etc to enter code I want

Sir I want to have something like this:

For a single pin 24 programming we have
tag1
tag2

tag1 to tag5 can be selected via pin 10 and pin 11 as a counter

Here in the code for now only 2 tag i.e. tag1 and tag2 is programmed to show the basic requirement needed to accomplish the goal

For tag1 the output led match for pin 24 is decided by pin 23 and pin 22 (as counter)

For tag2 the output led match for pin 24 is decided by pin 27 and pin 26 (as counter)

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int tag = 1;
int value = 4;
int pin = 24;

int val24 = 4;
int val25 = 4;
int val26 = 4;
int val27 = 4;

int LEDState=0;

const byte  ValuePluss = 10;    // for increment
const byte  ValueMinus = 11;    // for decrement
const byte  buttonPin1 = 22;    // the pin that the pushbutton is attached to
const byte  buttonPin2 = 23;
const byte  buttonPin3 = 24;    
const byte  buttonPin4 = 25;
const byte  buttonPin5 = 26;    
const byte  buttonPin6 = 27;

// const byte  ledPinA = 4;       // the pin that the LED is attached to
// const byte  ledPinB = 5;
// const byte  ledPinC = 6;       // the pin that the LED is attached to
// const byte  ledPinD = 7;

#define LED_NUMBER 4

#define ledPinA  4
#define ledPinB  5
#define ledPinC  6
#define ledPinD  7
byte LEDPinArray[LED_NUMBER] = { ledPinA,
                                 ledPinB,
                                 ledPinC,
                                 ledPinD };


long randNumber;
const byte startPin = A3;
int aRandomNumber = random(0,4);


void setup() {
  // put your setup code here, to run once:
   lcd.init();
   lcd.backlight();

   pinMode(ValuePluss, INPUT_PULLUP);
   pinMode(ValueMinus, INPUT_PULLUP);
   pinMode(buttonPin1, INPUT_PULLUP);
   pinMode(buttonPin2, INPUT_PULLUP);
   pinMode(buttonPin3, INPUT_PULLUP);
   pinMode(buttonPin4, INPUT_PULLUP);
   pinMode(buttonPin5, INPUT_PULLUP);
   pinMode(buttonPin6, INPUT_PULLUP);

   pinMode(ledPinA, OUTPUT);
   digitalWrite(ledPinA, LOW);
   pinMode(ledPinB, OUTPUT);
   digitalWrite(ledPinB, LOW);
   pinMode(ledPinC, OUTPUT);
   digitalWrite(ledPinC, LOW);
   pinMode(ledPinD, OUTPUT);
   digitalWrite(ledPinD, LOW);

   lcd.setCursor(8, 0);
   lcd.print("Pin-");
   lcd.setCursor(11, 0);
   lcd.print(pin);
   
   lcd.setCursor(8, 1);
   lcd.print("Eval-");
   lcd.setCursor(13, 1);
   lcd.print(value);

   lcd.setCursor(0, 0);
   lcd.print("tag- ");
   lcd.setCursor(5, 0);
   lcd.print(tag);


   // randomSeed(analogRead(0));

   // pinMode(startPin, INPUT_PULLUP);
   // lcd.setCursor(0, 0);
   // lcd.print("Press");

   // while (digitalRead(startPin) == HIGH)  //wait for the button to be pressed
   //  {
   //      //do nothing
   //  }
   //  randomSeed(micros());
   //     //a random number between 0 and 3
   //  // Serial.print("the random number is ");
   //  // Serial.println(aRandomNumber);
   //  lcd.setCursor(0, 1);
   //  lcd.print("numbr");
   //  lcd.setCursor(5, 1);
   //  lcd.print(aRandomNumber);

}

void loop() {
  // put your main code here, to run repeatedly:

      // randNumber = random(68);
      // // Serial.println(randNumber);
      // delay(50);

   if(!digitalRead(10))
        {
         if(tag<5)
         {
            tag=tag+1;
         }
         else
         {
            tag=1;
         }
          delay(100);
          lcd.setCursor(0, 0);
          lcd.print("tag- ");
          lcd.setCursor(5, 0);
          lcd.print(tag);
        }

   if(!digitalRead(11))
        {
         if(tag>1)
         {
            tag=tag-1;
         }
         else
         {
            tag=5;
         }
          delay(100);
          lcd.setCursor(0, 0);
          lcd.print("tag- ");
          lcd.setCursor(5, 0);
          lcd.print(tag);
        }


   if(tag==1)
   {

      if(!digitalRead(23))
        {
         if(val24<7)
         {
            val24=val24+1;
         }
         else
         {
            val24=4;
         }
          delay(100);
          lcd.setCursor(8, 1);
          lcd.print("Eval-");
          lcd.setCursor(13, 1);
          lcd.print(" ");
          lcd.setCursor(13, 1);
          lcd.print(val24);
        }

      if(!digitalRead(22))
        {
         if(val24>4)
         {
            val24=val24-1;
         }
         else
         {
            val24=7;
         }
          delay(100);
          lcd.setCursor(8, 1);
          lcd.print("Eval-");
          lcd.setCursor(13, 1);
          lcd.print(" ");
          lcd.setCursor(13, 1);
          lcd.print(val24);
        }

         lcd.setCursor(13, 1);
         lcd.print(val24);
      
   if(!digitalRead(24))
   {
      // digitalWrite(LEDPinArray[2], HIGH);
      digitalWrite(val24, HIGH);
      lcd.setCursor(0, 1);
      lcd.print("Oval-");
      lcd.setCursor(5, 1);
      lcd.print(val24);
      
   }
   else
   {
      digitalWrite(val24, LOW);
   }

   }



   if(tag==2)
   {

      if(!digitalRead(27))
        {
         if(val25<7)
         {
            val25=val25+1;
         }
         else
         {
            val25=4;
         }
          delay(100);
          lcd.setCursor(8, 1);
          lcd.print("Eval-");
          lcd.setCursor(13, 1);
          lcd.print(" ");
          lcd.setCursor(13, 1);
          lcd.print(val25);
        }

      if(!digitalRead(26))
        {
         if(val25>4)
         {
            val25=val25-1;
         }
         else
         {
            val25=7;
         }
          delay(100);
          lcd.setCursor(8, 1);
          lcd.print("Eval-");
          lcd.setCursor(13, 1);
          lcd.print(" ");
          lcd.setCursor(13, 1);
          lcd.print(val25);
        }

        lcd.setCursor(13, 1);
        lcd.print(val25);

      

   if(!digitalRead(24))
   {
      // digitalWrite(LEDPinArray[2], HIGH);
      digitalWrite(val25, HIGH);
      lcd.setCursor(0, 1);
      lcd.print("Oval-");
      
   }
   else
   {
      digitalWrite(val25, LOW);
   }

   }

   if(tag==3)
   {
   }

   if(tag==4)
   {
   }
      
}
      


After getting restart or reset of the system

The value of pin 24 for both tag1 and tag2 gets reset to led at pin 4
and again need to program it again

Working on the code to make it compact and less complex
as for each tag a pair of pin is required to program the related tag

Please check and help me in designing such a system with this kind of working :blush:

You originally said

Is that still what you want ?

Any how manage to show the TYPE of function I want to have

Though this code below has many errors and unwanted junk that is no longer needed to operate but as beginner I am having a focus on target to show what actually I want

It is just a system to explain the read write operation I want
I want a compact one actually on the basis of the explanation

Please check as it is for 2 input only for now !!!!!

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int tag = 1;
int value = 4;
int pin = 24;

int LoopState1 = 0;
int LoopState2 = 0;

boolean ledstate1 = false;
boolean ledstate2 = false;
boolean ledstate3 = false;

int mag = 1;

int val1 = 4;
int val2 = 4;
int val3 = 4;
int val4 = 4;

int val24 = 4;
int val25 = 4;
int val26 = 4;
int val27 = 4;

int LEDState=0;

const byte  ValuePluss = 10;    // for increment
const byte  ValueMinus = 11;    // for decrement

const byte  buttonPin1 = 22;    // the pin that the pushbutton is attached to
const byte  buttonPin2 = 23;
const byte  buttonPin3 = 24;    
const byte  buttonPin4 = 25;
const byte  buttonPin5 = 26;    
const byte  buttonPin6 = 27;

const byte  EditPin = 49;

// const byte  ledPinA = 4;       // the pin that the LED is attached to
// const byte  ledPinB = 5;
// const byte  ledPinC = 6;       // the pin that the LED is attached to

const byte  EditLed = 13;

#define LED_NUMBER 4

#define ledPinA  4
#define ledPinB  5
#define ledPinC  6
#define ledPinD  7
byte LEDPinArray[LED_NUMBER] = { ledPinA,
                                 ledPinB,
                                 ledPinC,
                                 ledPinD };


long randNumber;
const byte startPin = A3;
int aRandomNumber = random(0,4);

  int buttonPushCounter = 0;   // counter for the number of button presses
  boolean buttonState = 0;         // current state of the button
  boolean lastButtonState = 0;

  int buttonPushCounter1 = 0;   // counter for the number of button presses
  boolean buttonState1 = 0;         // current state of the button
  boolean lastButtonState1 = 0;

  int buttonPushCounter2 = 0;   // counter for the number of button presses
  boolean buttonState2 = 0;         // current state of the button
  boolean lastButtonState2 = 0;

  int buttonPushCounterA = 0;   // counter for the number of button presses
  boolean buttonStateA = 0;         // current state of the button
  boolean lastButtonStateA = 0;

  int buttonPushCounterB = 0;   // counter for the number of button presses
  boolean buttonStateB = 0;         // current state of the button
  boolean lastButtonStateB = 0;


void setup() {
  // put your setup code here, to run once:
   lcd.init();
   lcd.backlight();

   pinMode(ValuePluss, INPUT_PULLUP);
   pinMode(ValueMinus, INPUT_PULLUP);
   pinMode(buttonPin1, INPUT_PULLUP);
   pinMode(buttonPin2, INPUT_PULLUP);
   pinMode(buttonPin3, INPUT_PULLUP);
   pinMode(buttonPin4, INPUT_PULLUP);
   pinMode(buttonPin5, INPUT_PULLUP);
   pinMode(buttonPin6, INPUT_PULLUP);

   pinMode(ledPinA, OUTPUT);
   digitalWrite(ledPinA, LOW);
   pinMode(ledPinB, OUTPUT);
   digitalWrite(ledPinB, LOW);
   pinMode(ledPinC, OUTPUT);
   digitalWrite(ledPinC, LOW);
   pinMode(ledPinD, OUTPUT);
   digitalWrite(ledPinD, LOW);

   pinMode(EditLed, OUTPUT);
   digitalWrite(EditLed, LOW);

   lcd.setCursor(8, 0);
   lcd.print("Pin-");
   lcd.setCursor(12, 0);
   lcd.print(pin);
   
   lcd.setCursor(8, 1);
   lcd.print("Val-");
   lcd.setCursor(12, 1);
   lcd.print(value);

   // lcd.setCursor(0, 0);
   // lcd.print("tag-");
   // lcd.setCursor(4, 0);
   // lcd.print(tag);

}

void loop() {

   
   static unsigned long timer1 = 0;
   unsigned long interval1 = 20;

   if (millis() - timer1 >= interval1)
   {
      timer1 = millis();
      buttonState1 = digitalRead(EditPin);
      if (buttonState1 != lastButtonState1)
      {
         if (buttonState1 == LOW)
         {
            buttonPushCounter1++;
         }
          lastButtonState1 = buttonState1;
      }
   }
   if (buttonPushCounter1 % 2 == 0)// && buttonPushCounter > 0)
   {
      digitalWrite(EditLed, LOW); // INDICATOR OFF FOR EDITER OFF
        
        if(!digitalRead(22))// && tag==1)
        {
        ledstate1 = true;
        digitalWrite(val1, HIGH);
        lcd.setCursor(8, 0);
        lcd.print("Pin-");
        lcd.setCursor(12, 0);
        lcd.print("24");
        lcd.setCursor(8, 1);
        lcd.print("Val1-");
        lcd.setCursor(13, 1);
        lcd.print(val1);
        }
        else
        {
        digitalWrite(val1, LOW);
        }

   }
   else // BIG ELSE TO ENTER EDIT MODE
   {

      digitalWrite(EditLed, HIGH); // INDICATOR OFF FOR EDITER OFF
      // digitalWrite(ledPinA, HIGH); // INDICATOR ON


        static unsigned long timerA = 0;
        unsigned long intervalA = 20;

        if (millis() - timerA >= intervalA)
        {
         timerA = millis();
         buttonStateA = digitalRead(buttonPin1);
         if (buttonStateA != lastButtonStateA)
         {
           if (buttonStateA == LOW)
           {
            buttonPushCounterA++;
           }
            lastButtonStateA = buttonStateA;
         }
        } // END OF if (millis() - timer1 >= interval1)

         if (buttonPushCounterA % 2 == 0)// && buttonPushCounter > 0)
            {
               digitalWrite(val1, LOW);
            }
            else
            {
            digitalWrite(val1, HIGH);

            if(!digitalRead(22))// && tag==1)
            {
            digitalWrite(val1, HIGH);
            lcd.setCursor(8, 0);
            lcd.print("Pin-");
            lcd.setCursor(12, 0);
            lcd.print("24");
            lcd.setCursor(8, 1);
            lcd.print("Val1-");
            lcd.setCursor(13, 1);
            lcd.print(val1);
            }
            else
            {
            digitalWrite(val1, LOW);
            }

            if(!digitalRead(10))// && buttonStateA)// VAL1 COUNT UP
            {
               if(val1<7)
               {
                  val1=val1+1;
               }
               else
               {
                  val1=4;
               }
               delay(100);
               lcd.setCursor(8, 1);
               lcd.print("Val1-");
               lcd.setCursor(13, 1);
               lcd.print(val1);
            }  // PLUS COUNTER END
            if(!digitalRead(11))// && buttonStateA)// VAL1 COUNT DOWN
            {
               if(val1>4)
               {
                  val1=val1-1;
               }
               else
               {
                  val1=7;
               }
               delay(100);

               lcd.setCursor(8, 1);
               lcd.print("Val1-");
               lcd.setCursor(13, 1);
               lcd.print(val1);
            } // MINUS COUNTER END

            }

   }  // END of ELSE for val 1 project








   static unsigned long timer2 = 0;
   unsigned long interval2 = 20;

   if (millis() - timer2 >= interval2)
   {
      timer2 = millis();
      buttonState2 = digitalRead(EditPin);
      if (buttonState2 != lastButtonState2)
      {
         if (buttonState2 == LOW)
         {
            buttonPushCounter2++;
         }
          lastButtonState2 = buttonState2;
      }
   }
   if (buttonPushCounter2 % 2 == 0)// && buttonPushCounter > 0)
   {
      // digitalWrite(EditLed, LOW); // INDICATOR OFF FOR EDITER OFF
        
        if(!digitalRead(23))// && tag==1)
        {
      //   ledstate1 = true;
        digitalWrite(val2, HIGH);
        lcd.setCursor(8, 0);
        lcd.print("Pin-");
        lcd.setCursor(12, 0);
        lcd.print("25");
        lcd.setCursor(8, 1);
        lcd.print("Val2-");
        lcd.setCursor(13, 1);
        lcd.print(val2);
        }
        else
        {
        digitalWrite(val2, LOW);
        }
   }
   else // BIG ELSE TO ENTER EDIT MODE
   {
        static unsigned long timerB = 0;
        unsigned long intervalB = 20;

        if (millis() - timerB >= intervalB)
        {
         timerB = millis();
         buttonStateB = digitalRead(buttonPin2);
         if (buttonStateB != lastButtonStateB)
         {
           if (buttonStateB == LOW)
           {
            buttonPushCounterB++;
           }
            lastButtonStateB = buttonStateB;
         }
        } // END OF if (millis() - timer1 >= interval1)

       if (buttonPushCounterB % 2 == 0)// && buttonPushCounter > 0)
            {
               digitalWrite(val2, LOW);
            }
            else
            {
            digitalWrite(val2, HIGH);

            if(!digitalRead(23))// && buttonStateB)
            {
            digitalWrite(val2, HIGH);
            lcd.setCursor(8, 0);
            lcd.print("Pin-");
            lcd.setCursor(12, 0);
            lcd.print("25");
            lcd.setCursor(8, 1);
            lcd.print("Val2-");
            lcd.setCursor(13, 1);
            lcd.print(val2);
            }
            else
            {
            digitalWrite(val2, LOW);
            }

            if(!digitalRead(10))// && buttonStateB)
            {
               if(val2<7)
               {
                  val2=val2+1;
               }
               else
               {
                  val2=4;
               }
               delay(100);
               lcd.setCursor(8, 1);
               lcd.print("Val2-");
               lcd.setCursor(13, 1);
               lcd.print(val2);
            }  // PLUS COUNTER END
            if(!digitalRead(11))// VAL1 COUNT DOWN
            {
               if(val2>4)
               {
                  val1=val2-1;
               }
               else
               {
                  val2=7;
               }
               delay(100);

               lcd.setCursor(8, 1);
               lcd.print("Val2-");
               lcd.setCursor(13, 1);
               lcd.print(val2);
            } // MINUS COUNTER END

            }
   
   }  // END OF ELSE of val2 project



} // VOID END

EXPLANATION HERE :-

Pin 10 and 11 is for Up and DOWN of a counter which decides data for a pin

pin 22 and 23 are the 2 inputs taking into account

Here the additional thing added is the edit button at pin 49

So how it goes :-

Press EDIT

Press 22 to select or unlock the 'write to 22'
Press UP or DOWN button to select the LED match for the input 22
Now press 22 again to lock

Next press 23 to select or unlock
Press UP or DOWN button to select LED output match
Now press 23 again to lock it

Now Press EDIT button again

Now press Button 22 and the matched output LED starts glowing as the key pressed and goes OFF after the release of Button 22

Same thing ll be observed for Button 23 too

After getting entered into the EDIT mode we can select or unlock any of the Input button randomly but rest of the sequence ll be as per the directions given or it ll effect the proper functioning

This kind of system is having lot of errors but it can show the reflection of the purpose required

Things must be like :-

There should not be a lock or unlock system for any random input
Just
Press EDIT button
select input in edit mode and change the data
select an other input in edit mode and change the data
Then exit from EDIT mode

Making such a complex code is the reason behind the clash of data writing between 2 inputs

Previously For Input 23
Data of input 22 gets effected and copied the data from 23
and 23 remains same
Therefore all these Edit and lock unlock and so many button state things are added from internet

Working more than 24 hours
Please check and please comment that what attempts needed to set the goal

Please help me in completing this one
Thanks !!!!!!!