Storing chars and adding together

Hi,

I used a potentiometer and 2-leg pin. As I tweak with the potentiometer, corresponding letter to the sensor output is obtained. What I would like to do next is following:
when the button is pushed, the letter at that time is stored in a list and with each push and change in the potentiometer, new letter will be joined to the previous letter to generate words.

I actually need something like join() function in Python to combine letters and secondly, I would like to insert letters to a list.

Here is my questions :

  1. How can I add the new letter with the previous one?

  2. How can I assign these letters to an array ? Do I better use something like EEPROM ?

If you can show me a way or clarify these questions, that will be so useful to move on my project

Thank you in advance

const int analogInPin = A0;
int sensorValue = 0;
int outputValue = 0;
char letters = 0;
int buttonPin = 13;
int buttonDurum;

void setup() {
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);
  
  
}



void loop() {
  sensorValue = analogRead(analogInPin);
  outputValue = map(sensorValue, 0, 1023, 65, 90);
  char letters = outputValue;

  Serial.print(letters);
  Serial.print("\t");
  delay(100);
  buttonDurum = digitalRead(buttonPin);
  if (buttonDurum == LOW)
  {  

     Serial.print(letters);
    }
}
  1. How can I assign these letters to an array ?

Put the current letter straight into an array at the current array index position when the button becomes pressed then increment the array index variable ready for the next letter.

If you want to use the array of letter as a C style string then put a '\0' in the last position to terminate the string

when the button becomes pressed

Study this tutorial: https://www.arduino.cc/en/Tutorial/StateChangeDetection.

Thank you so much for the information! I will work on those

You turn pot and stop when the desired character appears on Serial Monitor. Now, you press the button to show the 5 characters' meaningful word.

if(digitalRead(buttonPin) == LOW)
{
   myArray[i] = letters;
   i++;
   myArray[i] = '\0';  //insert null character
   if(i == 5)
   {
       Serial.print(myArray);  //show word
       i = 0;    //reset array index
    }
}

moonBog:
I actually need something like join() function in Python to combine letters and secondly, I would like to insert letters to a list.

I think this is what you need to read:
https://www.tutorialspoint.com/cprogramming/c_strings.htm
And, in order to make sense out of that, it will help to know the difference between string literals and character literals.
https://www.tutorialspoint.com/cprogramming/c_constants.htm

When you read those two pages I linked, keep in mind the difference between 'A' (with single quotes) and "A" (with double quotes):

  • 'A' is one character (the capital letter A).
  • "A" is a two-element array. Its elements are 'A' and '\0', in that order. If you don't know what '\0' means, read the pages I linked, and you will find out.