58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
//
|
|
// FILE: HX_plotter.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// PURPOSE: HX711 demo
|
|
// URL: https://github.com/RobTillaart/HX711
|
|
|
|
|
|
#include "SevSeg.h"
|
|
#include "HX711.h"
|
|
|
|
HX711 scale;
|
|
|
|
// adjust pins if needed
|
|
uint8_t dataPin = A1;
|
|
uint8_t clockPin = A0;
|
|
|
|
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);
|
|
|
|
|
|
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.tare();
|
|
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
// continuous scale 4x per second
|
|
f = scale.get_units(1);
|
|
Serial.println(f);
|
|
delay(250);
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|