-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
HX_grocery_scale.ino
70 lines (50 loc) · 1.39 KB
/
HX_grocery_scale.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// FILE: HX_grocery_scale.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: HX711 demo
// URL: https://github.com/RobTillaart/HX711
//
// HISTORY:
// 0.1.0 2020-06-16 initial version
//
#include "HX711.h"
HX711 scale;
uint8_t dataPin = 6;
uint8_t clockPin = 7;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("LIBRARY VERSION: ");
Serial.println(HX711_LIB_VERSION);
Serial.println();
scale.begin(dataPin, clockPin);
Serial.print("UNITS: ");
Serial.println(scale.get_units(10));
Serial.println("\nEmpty the scale, press a key to continue");
while(!Serial.available());
while(Serial.available()) Serial.read();
scale.tare();
Serial.print("UNITS: ");
Serial.println(scale.get_units(10));
Serial.println("\nPut 1000 gr in the scale, press a key to continue");
while(!Serial.available());
while(Serial.available()) Serial.read();
scale.calibrate_scale(1000, 5);
Serial.print("UNITS: ");
Serial.println(scale.get_units(10));
Serial.println("\nScale is calibrated, press a key to continue");
while(!Serial.available());
while(Serial.available()) Serial.read();
scale.set_unit_price(0.031415); // we only have one price
}
void loop()
{
Serial.print("UNITS: ");
Serial.print(scale.get_units(5));
Serial.print("\t\tPRICE: ");
Serial.println(scale.get_price(5));
delay(250);
}
// -- END OF FILE --