0
0

arduinoでserial通信でjson形式のデータを読み込む方法

Last updated at Posted at 2024-05-21

arduinoでserial通信でjson形式のデータを読み込む方法

#include <Arduino_JSON.h>

void setup() {
    // シリアル通信を開始
    Serial.begin(9600);
}

void loop() {
    // シリアルポートにデータがあるかを確認
    if (Serial.available() > 0) {
        String input = Serial.readString();
        JSONVar instruct = JSON.parse(input);
        // {"serv_1": 5}
        Serial.println(instruct["serv_1"]);
    
    delay(1000);
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0