How to execute functions simultaneously in this case?

@blh64 thank you for your reply, I will test that tomorrow.

also, I am using websockets (GitHub - gilmaimon/ArduinoWebsockets: A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)) to toggle my pins.

void onMessageCallback(WebsocketsMessage message)
{
  deserializeJson(doc, message.data());

  std::string type = doc["data"]["type"];
  bool state = doc["active"];

  if (type == "stepper")
  {
    toggleStepper(state);
  }
  if (type == "light")
  {
    toggleLight(state);
  }
}

client.onMessage(onMessageCallback);

void loop()
{
  if (client.available())
  {
    client.poll();
  }
}

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