Is there a way to set Variable with Serial Monitor?

testing19
Posts: 1
Joined: Thu Apr 21, 2022 8:10 am

Is there a way to set Variable with Serial Monitor?

Postby testing19 » 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:
  1. #include <Preferences.h>
  2. Preferences preferences;
  3.  
  4. void setup() {
  5.   Serial.begin(115200);
  6.   String keyToAdd;
  7.  
  8.   String valueToAdd;
  9.  
  10.   keyToAdd = Serial.readString();
  11.   valueToAdd = Serial.readString();
  12.  
  13.   preferences.begin("licence",false);
  14.  
  15.   preferences.putString(keyToAdd.c_str(), valueToAdd);
  16.   preferences.getString("roomname_long",valueToAdd);
  17.   Serial.println(valueToAdd);
  18.   preferences.end();
  19. }
I want to put a new roomname_long So I write to the Monitor something like:
  1. roomname_long
And then should be the name of the value:
  1. Test
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

Who is online

Users browsing this forum: No registered users and 66 guests