add 7segment display
This commit is contained in:
parent
aa3bad78f3
commit
38913b68c7
2 changed files with 26 additions and 24 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
# HX711 Based Torque Measurement
|
# HX711 Based Torque Measurement
|
||||||
|
|
||||||
[SparkFun HX711 Load Cell Amp Board](https://www.sparkfun.com/sparkfun-load-cell-amplifier-hx711.html)
|
[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/)
|
[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/)
|
||||||
|
|
|
||||||
|
|
@ -5,52 +5,53 @@
|
||||||
// URL: https://github.com/RobTillaart/HX711
|
// URL: https://github.com/RobTillaart/HX711
|
||||||
|
|
||||||
|
|
||||||
#include "SevSeg.h"
|
|
||||||
#include "HX711.h"
|
#include "HX711.h"
|
||||||
|
#include "TM1637.h"
|
||||||
|
|
||||||
HX711 scale;
|
HX711 scale;
|
||||||
|
|
||||||
// adjust pins if needed
|
const int tm_clk = 2;
|
||||||
uint8_t dataPin = A1;
|
const int tm_dio = 3;
|
||||||
uint8_t clockPin = A0;
|
const uint8_t hx_dataPin = A1;
|
||||||
|
const uint8_t hx_clockPin = A0;
|
||||||
|
|
||||||
|
|
||||||
|
TM1637 tm1637(tm_clk, tm_dio);
|
||||||
|
|
||||||
|
float strain;
|
||||||
|
|
||||||
float f;
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
//
|
// setup display
|
||||||
byte numDigits = 4;
|
tm1637.init();
|
||||||
byte digitPins[] = {2, 3, 4, 5};
|
tm1637.set(BRIGHT_TYPICAL);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
|
||||||
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);
|
|
||||||
|
|
||||||
|
tm1637.displayStr((char *)"HI");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
// setup strain gauge amp
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
// Serial.println();
|
// Serial.println();
|
||||||
// Serial.println(__FILE__);
|
// Serial.println(__FILE__);
|
||||||
// Serial.print("HX711_LIB_VERSION: ");
|
// Serial.print("HX711_LIB_VERSION: ");
|
||||||
// Serial.println(HX711_LIB_VERSION);
|
// Serial.println(HX711_LIB_VERSION);
|
||||||
// Serial.println();
|
// Serial.println();
|
||||||
scale.begin(dataPin, clockPin);
|
scale.begin(hx_dataPin, hx_clockPin);
|
||||||
scale.set_scale(1); // TODO you need to calibrate this yourself.
|
scale.set_scale(100); // TODO you need to calibrate this yourself.
|
||||||
|
tm1637.displayStr((char *)"tArE");
|
||||||
|
Serial.println("TARE");
|
||||||
scale.tare();
|
scale.tare();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// continuous scale 4x per second
|
strain = scale.get_units(1);
|
||||||
f = scale.get_units(1);
|
Serial.println(strain);
|
||||||
Serial.println(f);
|
|
||||||
|
tm1637.displayNum(strain);
|
||||||
delay(250);
|
delay(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue