59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
//
|
|
// FILE: HX_plotter.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// PURPOSE: HX711 demo
|
|
// URL: https://github.com/RobTillaart/HX711
|
|
|
|
|
|
#include "HX711.h"
|
|
#include "TM1637.h"
|
|
|
|
HX711 scale;
|
|
|
|
const int tm_clk = 6;
|
|
const int tm_dio = 5;
|
|
const uint8_t hx_dataPin = A4;
|
|
const uint8_t hx_clockPin = A3;
|
|
|
|
|
|
TM1637 tm1637(tm_clk, tm_dio);
|
|
|
|
float strain;
|
|
|
|
|
|
|
|
void setup()
|
|
{
|
|
// 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(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()
|
|
{
|
|
strain = scale.get_units(1);
|
|
Serial.println(strain);
|
|
|
|
tm1637.displayNum(strain);
|
|
delay(250);
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|