How to read and show data?

my code converts a lowercase sentence to uppercase. I already declared the message in the program. I'd like to introduce the message by typing the keyboard, so how can I achieve this?
Here is my code:
/*
*Autor: Johann Whight
*lowercase to uppercase sentence converter
*/
int i;
void setup()
{
Serial.begin(9600);
char texto = "hi everyone";
for (i = 0; texto[i]; i++)
{
texto[i] = toupper(texto[i]);
}
Serial.println(texto);
}
void loop()
{
}

void setup() {
  Serial.begin(9600);
}
void loop() {
  if (Serial.available()) {
    char got = Serial.read();
    if (islower(got)) {
      got = toupper(got);
    }
    Serial.write(got);
  }
}

If lowercase convert to upper, echo unchanged if not.

1 Like

The test is not really necessary (won't hurt, looks good :wink: ), as toupper() of something that is already uppercase has no negative impact... so you can go with just

void setup() {
  Serial.begin(115200);  // serial monitor at 115200 bauds
}

void loop() {
  if (Serial.available()) Serial.write(toupper((char) Serial.read()));
}

This will work with standard ASCII, so you can't deal with é, à, ô etc
--> if you are using UTF8 beyond simple ASCII, then you need more code and it's not as easy

1 Like

Thanks a million my friend, yeah the standard ASCII is really helpfull, I forgot it. Really thanks a million :+1: :clap:

Thanks a million my friend, now I can see what are my mistakes, really thanks a million your answer is so helpfull.... :+1: :clap: :clap: :clap: