#include #include "HX711.h" //HX711に1~4までの番号を振り、それぞれが接続されているマイコンの端子の番号を指定する const int DT_PIN1 = 25; const int SCK_PIN1 = 29; const int DT_PIN2 = 33; const int SCK_PIN2 = 37; const int DT_PIN3 = 41; const int SCK_PIN3 = 45; const int DT_PIN4 = 49; const int SCK_PIN4 = 53; //重量格納変数 static float gram1 = 0; static float gram2 = 0; static float gram3 = 0; static float gram4 = 0; HX711 Scale1; HX711 Scale2; HX711 Scale3; HX711 Scale4; void setup() { Serial.begin(115200); Scale1.begin(DT_PIN1,SCK_PIN1); Scale2.begin(DT_PIN2,SCK_PIN2); Scale3.begin(DT_PIN3,SCK_PIN3); Scale4.begin(DT_PIN4,SCK_PIN4); //パラメーター設定 非荷重時0にする Scale1.set_scale(2280.f); Scale2.set_scale(2280.f); Scale3.set_scale(2280.f); Scale4.set_scale(2280.f); Scale1.tare(); Scale2.tare(); Scale3.tare(); Scale4.tare(); } void loop() { //ここで補正のためのパラメーターをかけるとともに、数字の単位をkgにする gram1 = Scale1.get_units(10);// * 0.058; gram2 = Scale2.get_units(10);// * 0.0552 gram3 = Scale3.get_units(10);// * 0.057; gram4 = Scale4.get_units(10);// * 0.0563; //重量表示 Serial.print("1 "); Serial.println(gram1); Serial.print("2 "); Serial.println(gram2); Serial.print("3 "); Serial.println(gram3); Serial.print("4 "); Serial.println(gram4); Serial.println(); }