Reset char array on lcd display

Hi All, I have a sketch with 5 buttons to control and lcd, the first button on a push increments through an array of characters abc ect and displays them on the lcd. the next button on a press saves the selected increment in an array and moves the cursor into the next position ready to select the next character untill a word is formed and saved into the array on the lcd . the next button on a push, saves the array to a desiginated eeprom address. i have another button that reads the eeprom address and the array saved at that address the next press of the button moves to the next eeprom address and displays it to the lcd. I have tried to put another button called enter and on a press clears the current selected array ready for it to be rewritten.

What i cant figure out is how to reset and change the char array so a new word can be edited so it can be saved to the next selected eeprom address.

#include <LiquidCrystal.h>
#include <EEPROM.h>
byte f;
int eeAddress = 0;
 const int button3 = 2;
const int button1 = 11;
const int button2 = 12;
const int button4 = 3;
const int readbut = A1;
int enterbut = A0;
 LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int counter = 0;
int sizeofprgn = 6;
int pos = 0;
int cpos1 = 0;
int cpos2 = 0;
int buttonState = 0;
int lastButtonState = 0;
int t =0;
int j=0;
int z;
int i =0;
boolean edit;
byte prgsize = 7;
byte EEPROMStartAdress = 0;
byte EEPROMAdress = 0;
int minusstate;
 int lastminusstate = HIGH;
int lastenter;
byte memsave;
//int eeAddress = 0;
 int butt = 5;
char prgn[] = " ram ";
//char rebuilt[] = " @sG7ujn >:e[|zwwqFRET"; // initial garbage
//char output[] = {'a','l','c','d','e','f','\0'};
const char* Editchars = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890,.!?&@#$%^*_-+=(){}[]<>|\\/'\"~";
void setup()
{
 lcd.begin(16,2);
 //lcd.print (output);
 Serial.begin(9600);
  
 //Setup some buttons
 pinMode (button1, INPUT);
 pinMode (button2, INPUT);
  pinMode (button3, INPUT); 
  pinMode (button4, INPUT);
  pinMode (readbut, INPUT);
  pinMode (enterbut, INPUT);
 //Turn the internal resistors on so the thing does go kaput
 digitalWrite(button1, HIGH);
 digitalWrite(button2, HIGH);
  digitalWrite(button3, HIGH);
  digitalWrite(button4, HIGH);
  digitalWrite(readbut, HIGH);
  digitalWrite(enterbut, HIGH);
}
 
void loop()
{
  
 //*******************Savetoarray,and move cursor***************
  buttonState = digitalRead(button2);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == LOW) {
      // if the current state is HIGH then the button
      // wend from off to on: for 
      
   i++;
     
   prgn[i] = Editchars[t];
    prgn[i +1] = '\0';
      
      j++;
      lcd.cursor();
      lcd.setCursor(j+7,cpos2);
     
      Serial.println("scroll");
       Serial.println(prgn);
  
      if (j >5)j=0;
        
      t=0;
  
    }
    } 
  lastButtonState = buttonState;
  
  //************** Char select***************************
 
  if(digitalRead(button1)==LOW){
  
   
    t++;
  

    lcd.setCursor(j+7,cpos1);
    
  lcd.print(Editchars[t]);
    
  
    delay(50);
    
  }
 
 
 // *****************Increment character back*************************************
  int minbut = digitalRead(button3);
  if(minbut!=lastminusstate){
 if(minbut == LOW) {
   t--;
  if(t<1) t=1;
    lcd.setCursor(j+7,cpos1);
    
  lcd.print(Editchars[t]);
 }
  } 
  
    lastminusstate = minbut;
 //***************saving to memory*********************
  
   if(digitalRead(button4)==LOW){ 
    
     
      
     
      lcd.cursor();
      lcd.setCursor(j+7,cpos1);
     
       Serial.print(prgn);
     Serial.print(" put");  
     
  EEPROMStartAdress=EEPROMStartAdress+1;
     memsave = EEPROMStartAdress * prgsize;
      EEPROM.put(memsave, prgn);
  if(EEPROMStartAdress > 5) EEPROMStartAdress = 0;
     Serial.print(memsave );
   Serial.println("\t");
   
     lcd.clear();
     j =0;
     t=0;
    i=0;
   lcd.setCursor (j+7,cpos2);
  lcd.print(Editchars[t]);
      lcd.print("Save");
     delay(100);
     lcd.clear();
lcd.setCursor (j+7,cpos1);
    
     
   }
   
   
   //************************reading from memory************
  
  if(digitalRead(readbut)==LOW){
 
    
    EEPROMAdress=EEPROMAdress+1;
    byte memcall = EEPROMAdress * prgsize;
    EEPROM.get(memcall, prgn);
      if(EEPROMAdress > 5) EEPROMAdress = 0;
 
    Serial.println("   ");
    Serial.print(" get  ");
    Serial.print( memcall );
      
   
                
    
  Serial.print(prgn);
  
    lcd.clear();
    delay(100);
    
   
  lcd.setCursor (j+7,cpos2); 
   lcd.print(prgn);
     
   

    }
  //**********************entermode**********************
int enter = digitalRead(enterbut);

  // compare the buttonState to its previous state
  if (enter != lastenter) {
    // if the state has changed, increment the counter
    if (enter == LOW) {
      // if the current state is HIGH then the button
      // wend from off to on: for 
      
 
    // for(i=0; i<sizeofprgn;i++){
  // prgn[i] = Editchars[i];
  memset(prgn, 0, sizeof prgn);
   // prgn[i] = 0;
  
     //}
     Serial.print("Enter");
      Serial.print(prgn);
     }
    
    } 
  lastenter = enter;
  


}


Please read the post at the top of the forum about how to correctly post your code. Then, go back and edit your code. It will help people help you.

As is, it is difficult to follow and some of the text is garbled.

Apologies its been a couple of years since i have posted anything.

It looks like you are trying to write BASIC code. Not all variables need to be global and you can pick much more descriptive names than 'i', 'j', 'k', etc.
I can't test this, but it does compile. You have to set your word index counter back to zero when you press the ENTER button

#include <LiquidCrystal.h>
#include <EEPROM.h>

// Button assignment and definitions
const int button[] = { 11, 12, 2, 3, A1, A0 };
const int numButtons = sizeof(button) / sizeof(button[0]);
enum { B_SEL, B_INC, B_DEC, B_SAVE, B_READ, B_ENTER };

int lastButtonState[numButtons];

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

byte EEPROMStartAdress = 0;

const char* Editchars = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890,.!?&@#$%^*_-+=(){}[]<>|\\/'\"~";

char prgn[] = " ram ";
int selectIdx = 0;  //int t = 0;
int columnIdx = 0; //int j = 0;
int wordIdx = 0;  // int i = 0;


void setup()
{
  lcd.begin(16, 2);
  //lcd.print (output);
  Serial.begin(9600);

  for ( int i = 0; i < numButtons; ++i ) {
    pinMode (button[i], INPUT_PULLUP);
  }
}

void loop()
{
  int buttonState;

  //*******************Savetoarray,and move cursor***************
  buttonState = digitalRead(button[B_INC]);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState[B_INC]) {
    if (buttonState == LOW) {
      wordIdx++;

      prgn[wordIdx] = Editchars[selectIdx];
      prgn[wordIdx + 1] = '\0';

      columnIdx++;
      lcd.cursor();
      lcd.setCursor(columnIdx + 7, 0);

      Serial.println("scroll");
      Serial.println(prgn);

      if (columnIdx > 5) columnIdx = 0;
      selectIdx = 0;
    }
  }
  lastButtonState[B_INC] = buttonState;

  //************** Char select***************************

  if (digitalRead(button[B_SEL]) == LOW) {
    selectIdx++;
    lcd.setCursor(columnIdx + 7, 0);
    lcd.print(Editchars[selectIdx]);
    delay(50);
  }


  // *****************Increment character back*************************************
  buttonState = digitalRead(button[B_DEC]);
  if (buttonState != lastButtonState[B_DEC]) {
    if (buttonState == LOW) {
      selectIdx--;
      if (selectIdx < 1) selectIdx = 1;
      lcd.setCursor(columnIdx + 7, 0);
      lcd.print(Editchars[selectIdx]);
    }
  }
  lastButtonState[B_DEC] = buttonState;

  //***************saving to memory*********************

  if (digitalRead(button[B_SAVE]) == LOW) {
    lcd.cursor();
    lcd.setCursor(columnIdx + 7, 0);

    Serial.print(prgn);
    Serial.print(" put");

    EEPROMStartAdress++;
    byte memsave = EEPROMStartAdress * sizeof(prgn);
    EEPROM.put(memsave, prgn);
    if (EEPROMStartAdress > 5) EEPROMStartAdress = 0;
    Serial.println(memsave );

    lcd.clear();
    columnIdx = 0;
    selectIdx = 0;
    wordIdx = 0;
    lcd.setCursor (columnIdx + 7, 0);
    lcd.print(Editchars[selectIdx]);
    lcd.print("Save");
    delay(100);
    lcd.clear();
    lcd.setCursor (columnIdx + 7, 0);
  }


  //************************reading from memory************

  if (digitalRead(button[B_READ]) == LOW) {
    EEPROMStartAdress++;
    byte memcall = EEPROMStartAdress * sizeof(prgn);
    EEPROM.get(memcall, prgn);
    if (EEPROMStartAdress > 5) EEPROMStartAdress = 0;

    Serial.println();
    Serial.print(" get  ");
    Serial.print( memcall );

    Serial.print(prgn);
    lcd.clear();
    delay(100);
    lcd.setCursor (columnIdx + 7, 0);
    lcd.print(prgn);
  }

  //**********************entermode**********************
  buttonState = digitalRead(button[B_ENTER]);

  if (buttonState != lastButtonState[B_ENTER]) {
    if (buttonState == LOW) {
      memset(prgn, 0, sizeof prgn);
      wordIdx = 0;

      Serial.print("Enter");
      Serial.print(prgn);
    }
  }
  lastButtonState[B_ENTER] = buttonState;
}

Thanks!!! nice formatting.

What is the best way to synchronize the buttons, that reads (readbutton) the eeprom(eeprom get) so you can edit and with the save button (eeprom put) save to the same address you are reading from. any help would be great.

I'm not sure what you mean by this. You test each button inside loop() and act accordingly. I don't see an synchronization issues.