Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Complete project details at https://RandomNerdTutorials.com/arduino-load-cell-hx711/
- *
- * HX711 library for Arduino - example file
- * https://github.com/bogde/HX711
- *
- * MIT License
- * (c) 2018 Bogdan Necula
- *
- **/
- #include <Arduino.h>
- #include "HX711.h"
- // HX711 circuit wiring
- const int LOADCELL_DOUT_PIN = 4;
- const int LOADCELL_SCK_PIN = 5;
- const int pin2 = 2;
- const int pin3 = 3;
- const int pin6 = 6;
- const int pin7 = 7;
- const int pin8 = 8;
- const int pin9 = 9;
- HX711 scale;
- HX711 scale2;
- HX711 scale3;
- HX711 scale4;
- void setup() {
- Serial.begin(57600);
- scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
- scale2.begin(pin2, pin3) ;
- scale3.begin(pin6, pin7) ;
- scale4.begin(pin8, pin9) ;
- scale.set_scale(18.89);
- scale2.set_scale(18.89);
- scale3.set_scale(18.89);
- scale4.set_scale(18.89);
- scale.tare();
- scale2.tare();
- scale3.tare();
- scale4.tare();
- //vitale
- pinMode (12, INPUT); //triggerpin
- pinMode (13, OUTPUT); //echopin
- }
- void loop() {
- digitalWrite (13, LOW);
- digitalWrite (13, HIGH);
- delay (10);
- digitalWrite (13, LOW);
- long durata = pulseIn(12, HIGH);
- long distanza = 0.034 * durata / 2;
- int altezza = 200 - distanzaa;
- Serial.print("altezza:");
- Serial.println(altezza);
- //Serial.println(scale2.get_units(10), 5);
- long lettura = ((scale.get_units(5) + scale2.get_units(5) + scale3.get_units(5) + scale4.get_units(5))/4) ;
- /// Serial.println(lettura);
- String stringOne = String(lettura) ;
- stringOne = stringOne + "g" ;
- Serial.println(stringOne);
- }
Advertisement
Add Comment
Please, Sign In to add comment