Is there a way to set Variable with Serial Monitor?
Posted: Thu Apr 21, 2022 8:24 am
I try to find out if I can set Variables with the given Serial Monitor of the arduino IDE
I had this code:
I want to put a new roomname_long So I write to the Monitor something like:
And then should be the name of the value:
And if I press the read button on my Esp32 it should give me the new name for roomname_long but it doesn´t work
I had this code:
- #include <Preferences.h>
- Preferences preferences;
- void setup() {
- Serial.begin(115200);
- String keyToAdd;
- String valueToAdd;
- keyToAdd = Serial.readString();
- valueToAdd = Serial.readString();
- preferences.begin("licence",false);
- preferences.putString(keyToAdd.c_str(), valueToAdd);
- preferences.getString("roomname_long",valueToAdd);
- Serial.println(valueToAdd);
- preferences.end();
- }
- roomname_long
- Test