-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththrustSensor.ino
More file actions
31 lines (24 loc) · 782 Bytes
/
thrustSensor.ino
File metadata and controls
31 lines (24 loc) · 782 Bytes
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
#include "HX711.h"
HX711 scale(A1, A0); // parameter "gain" is ommited; the default value 128 is used by the library
const int buttonPin = 2; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
Serial.begin(38400);
Serial.println("Thrust Sensor Initialized");
Serial.println("Output in form milliseconds since init, calibrated force in grams");
scale.set_scale(83.f);
scale.tare();
}
void loop() {
if (buttonState == LOW && digitalRead(buttonPin) == HIGH) {
Serial.println("Tare to 0.");
buttonState = HIGH;
scale.tare();
}
else {
buttonState = LOW;
}
Serial.print(millis());
Serial.print(",");
Serial.println(scale.get_units(1), 0);
}