#include "ArduinoJson.h" int analogPin = 3; int data = 0; char userInput; char* commandVer; void setup() { // put your setup code here, to run once: pinMode(LED_BUILTIN, OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()>0) { //userInput = Serial.read(); // String input; //{ "command": "switch", "arg": "one", "state": "off", "ver":"1690931931"} StaticJsonDocument<96> jsonin; DeserializationError error = deserializeJson(jsonin, Serial); if (error) { Serial.print(F("deserializeJson() failed: ")); Serial.println(error.f_str()); return; } const char* command = jsonin["command"]; // "switch" const char* arg = jsonin["arg"]; // "one" const char* state = jsonin["state"]; // "off" const char* ver = jsonin["ver"]; // "1690931931" StaticJsonDocument<96> jsonout; jsonout["command"] = "lol"; jsonout["arg"] = "rofl"; jsonout["state"] = "on"; jsonout["ver"] = "1690931337"; serializeJson(jsonout, Serial); /* Serial.print(command); Serial.print(" - "); Serial.print(arg); Serial.print(" - "); Serial.print(state); Serial.print(" - "); Serial.println(ver); if(userInput == 'g') { data = analogRead(analogPin); */ /* digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(200); digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(200); digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(200); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(200); //delay(2000); Serial.println(data); */ //} } }