Having trouble with adding char and char* with buttons on ESP32

I am trying to program my ESP 32 so that when I press a few buttons I can enter the ssid and pass of a wifi network. I want to use one button to go forward in the alphanumerics one to go back and one for capitalization. The final button is for saving each successive letter/number.

The code I have written so far is as follows:

#define IO14_BTN 14
#define IO27_BTN 27
#define IO19_BTN 19
#define IO0_BTN 0

char * AN = "abcdefghijklmnopqrstuvwxyz0123456789";
char * ANC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

void setup() {
  Serial.begin(115200);

  pinMode(IO14_BTN, INPUT_PULLUP);
  pinMode(IO27_BTN, INPUT_PULLUP);
  pinMode(IO19_BTN, INPUT_PULLUP);
  pinMode(IO0_BTN, INPUT_PULLUP);
}

void loop() {

Serial.println("Begining Entry.");

  int count = 0;
  int wlen = 0;
  bool isCap = false;

  char * word[15];
  char let = 'a';

  while (1) {
    if(digitalRead(IO19_BTN) == LOW){
      count ++;
      if (count == 36){
        count = 0;
      }

      let = AN[count];

      delay(100);
    }
    if(digitalRead(IO14_BTN) == LOW){
      count --;
      if (count == -1){
        count = 35;
      }

      let = AN[count];

      delay(100);
    }

    if(digitalRead(IO27_BTN) == LOW){
      
      if(!isCap) {
        let = ANC[count];

        isCap = true;
      } else {
        let = AN[count];

        isCap = false;
      }

      delay(100);
    }

    if(digitalRead(IO0_BTN) == LOW){

      Serial.println("Saving letter.");

      if(wlen <= 15){
        word[1] + let;
        wlen ++;
      } else {
        Serial.println("Char limit reached.");
      }
      delay(100);
    }
    
    Serial.println("SSID:");
    Serial.print(word[1]);
    Serial.println(let);
    delay(100);
  }

}


This code works for scrolling forwards and back through the letters and numbers and also for capitalization of the letters but when I press IO0_BTN to try and save it the letter seems to not save into the char* word[15], I'm not sure what I'm doing wrong as I am quite new to this and any help would be much appreciated. If this is poorly explained and anyone needs any clarification I'm happy to offer it.

Don't you want to actually use the result of this expression?

yes, ideally I want it saved into the word variable so that I can use it elsewhere, I'm getting very confused with adding chars to char* or concatenating strings.

You would normally use strcat() for string concatenation. Unless, you want to do it manually (custom code).

Does, "ideally I want it", mean "I have no idea how to..." ?

I've seen a lot of strcat() when looking for a solution to this but doesn't it only work for strings? will it work for character arrays?

A C string is a character array.

what is this supposed to do? at the moment it does nothing, I wonder if compiler even kept it

It was my understanding that this would add the char let to the char * array. If this is not what it does, how does one do this? Would I need to use strcpy() and strcat()?

smartphones are almost always available how about using a smartphone and a WiFi-manager-library?

The WiFi-manager-library creates an access-point.
You connect your smartphone to this accesspoint and then you can use the browser on your smartphone to enter SSID and password.
The WiFi-manager stores the WiFi-credentials in the ESP32 to connect to this WiFi-network

This one seems to have a good description and seems to be easy to use

best regards Stefan

Are you copy pasting and splicing someone else’s code? If so then I suggest you look up what assignment operator does.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.