mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
55 lines
942 B
C++
55 lines
942 B
C++
//
|
|
// FILE: HX_plotter.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// VERSION: 0.1.0
|
|
// PURPOSE: HX711 demo
|
|
// URL: https://github.com/RobTillaart/HX711
|
|
//
|
|
// HISTORY:
|
|
// 0.1.0 2020-06-15 initial version
|
|
//
|
|
|
|
|
|
#include "HX711.h"
|
|
|
|
HX711 scale;
|
|
|
|
uint8_t dataPin = 6;
|
|
uint8_t clockPin = 7;
|
|
|
|
uint32_t start, stop;
|
|
volatile float f;
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
// Serial.println(__FILE__);
|
|
// Serial.print("LIBRARY VERSION: ");
|
|
// Serial.println(HX711_LIB_VERSION);
|
|
// Serial.println();
|
|
|
|
scale.begin(dataPin, clockPin);
|
|
|
|
// TODO find a nice solution for this calibration..
|
|
// load cell factor 20 KG
|
|
// scale.set_scale(127.15);
|
|
// load cell factor 5 KG
|
|
scale.set_scale(420.0983); // TODO you need to calibrate this yourself.
|
|
// reset the scale to zero = 0
|
|
scale.tare();
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
// continuous scale 4x per second
|
|
f = scale.get_units(5);
|
|
Serial.println(f);
|
|
delay(250);
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|
|
|