Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "HX711.h"
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- #define DOUT 3
- #define CLK 2
- HX711 scale;
- float calibration_factor = -46000;
- void setup() {
- scale.begin(DOUT, CLK);
- scale.set_scale();
- scale.tare();
- long zero_factor = scale.read_average();
- lcd.begin(16, 2);
- lcd.print(" MIERNIK ");
- lcd.setCursor(0,1);
- lcd.print(" TENSOMETRYCZNY ");
- delay(2000);
- lcd.clear();
- }
- void loop() {
- scale.set_scale(calibration_factor);
- float reading = scale.get_units();
- if (reading < 0.09)
- reading = 0;
- lcd.setCursor(0,0);
- lcd.print("Sila nacisku:");
- int o3 = 0;
- float w = (reading * 9.81)*100;
- w = floor(w);
- int o1 = (int)w%10;
- int o2 = ((int)w%100 - o1)/10;
- if (w > 10000)
- o3 = ((int)w%100000 - o2)/100;
- else if (w > 1000)
- o3 = ((int)w%10000 - o2)/100;
- else
- o3 = ((int)w%1000 - o2)/100;
- lcd.setCursor(0,1);
- lcd.print(" ");
- lcd.setCursor(0,1);
- lcd.print(o3);
- lcd.print(".");
- lcd.print(o2);
- lcd.print(o1);
- lcd.print(" N ");
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement