#include // https://github.com/bogde/HX711 #include "HX711.h" const int DT_PIN = 1; const int SCK_PIN = 0; HX711 Scale; void setup() { Serial.begin(9600); Scale.begin(DT_PIN, SCK_PIN); //パラメータ設定 Scale.set_scale(-386.3); Scale.tare(); } //重量格納変数 int gram = 0; void loop() { //重量を四捨五入 gram = Scale.get_units(10) + 0.5; //重量表示 Serial.write(map(gram, 0, 1000, 0, 255)); Scale.power_down(); delay(5000); Scale.power_up(); }