#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <HX711.h>
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
Adafruit_ILI9341 TFT = Adafruit_ILI9341 (TFT_CS, TFT_DC, TFT_RST);
HX711 scale;
int weightb = 0;
int buttonpin = 3;
void setup() {
TFT.begin();
TFT.setRotation(0);
TFT.fillScreen(ILI9341_BLACK);
TFT.setTextSize(3);
TFT.setCursor(10,10);
Serial.begin(9600);
scale.begin(A1, A0);
pinMode(buttonpin, INPUT_PULLUP); // gumb na vhodnem pinu 2 z integriranim pull up uporom
}
void loop() {
int buttonstate = digitalRead(buttonpin);
int weight = scale.get_units();
if (weight != weightb) {
TFT.fillScreen(ILI9341_BLACK);
TFT.setCursor(10,10);
TFT.print(weight);
TFT.print( "KG");
weightb = weight;
}
if(buttonstate == LOW) {
weight = 0;
}
}