diff --git a/README.md b/README.md index 29e50b6..9b4eb51 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # HX711 Based Torque Measurement [SparkFun HX711 Load Cell Amp Board](https://www.sparkfun.com/sparkfun-load-cell-amplifier-hx711.html) - [Arduino Library by Rob Tillaart](https://github.com/RobTillaart/HX711/) +[AZ Delivery 7-segment display](https://www.az-delivery.de/en/products/4-digit-display) +[seeed studio Grove Display Driver](https://github.com/Seeed-Studio/Grove_4Digital_Display/) diff --git a/arduino_strain.ino b/arduino_strain.ino index 7c75e8e..31bd8bb 100644 --- a/arduino_strain.ino +++ b/arduino_strain.ino @@ -5,52 +5,53 @@ // URL: https://github.com/RobTillaart/HX711 -#include "SevSeg.h" #include "HX711.h" +#include "TM1637.h" HX711 scale; -// adjust pins if needed -uint8_t dataPin = A1; -uint8_t clockPin = A0; +const int tm_clk = 2; +const int tm_dio = 3; +const uint8_t hx_dataPin = A1; +const uint8_t hx_clockPin = A0; + + +TM1637 tm1637(tm_clk, tm_dio); + +float strain; -float f; void setup() { -// - byte numDigits = 4; - byte digitPins[] = {2, 3, 4, 5}; - byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; - bool resistorsOnSegments = false; // 'false' means resistors are on digit pins - byte hardwareConfig = COMMON_ANODE; // See README.md for options - bool updateWithDelays = false; // Default 'false' is Recommended - bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros - bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[] - - sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, - updateWithDelays, leadingZeros, disableDecPoint); + // setup display + tm1637.init(); + tm1637.set(BRIGHT_TYPICAL);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7; + tm1637.displayStr((char *)"HI"); + delay(1000); + // setup strain gauge amp Serial.begin(115200); // Serial.println(); // Serial.println(__FILE__); // Serial.print("HX711_LIB_VERSION: "); // Serial.println(HX711_LIB_VERSION); // Serial.println(); - scale.begin(dataPin, clockPin); - scale.set_scale(1); // TODO you need to calibrate this yourself. + scale.begin(hx_dataPin, hx_clockPin); + scale.set_scale(100); // TODO you need to calibrate this yourself. + tm1637.displayStr((char *)"tArE"); + Serial.println("TARE"); scale.tare(); - } void loop() { - // continuous scale 4x per second - f = scale.get_units(1); - Serial.println(f); + strain = scale.get_units(1); + Serial.println(strain); + + tm1637.displayNum(strain); delay(250); }