Hi Class,
This code compiles:
#include <Arduino.h>
#include <HX711_ADC.h>
#include <TM1637TinyDisplay6.h>
#include <Keypad.h>
// HX711 circuit wiring
const int HX711_dout = 4;
const int HX711_sck = 5;
// TM1637 - 6 pinos
const int CLK = 3;
const int DIO = 2;
HX711_ADC balanca(HX711_dout, HX711_sck);
TM1637TinyDisplay6 display(CLK, DIO);
#define ROW_NUM 4 //4 linhas
#define COLUMN_NUM 4 //4 colunas
char keys[ROW_NUM][COLUMN_NUM] = {
{'7', '8', '9', 'A'},
{'4', '5', '6', 'B'},
{'1', '2', '3', 'X'},
{'0', '.', 'C', 'D'}
};
byte pin_rows[ROW_NUM] = {8, 9, 10, 11};
byte pin_column[COLUMN_NUM] = {12, 13, 14, 15};
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
char key = keypad.getKey();
float calibrationValue;
unsigned long t = 0;
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
display.begin();
display.setBrightness(7);
balanca.begin();
calibrationValue = 158.20;
unsigned long stabilizingtime = 2000;
boolean _tare = true;
balanca.start(stabilizingtime, _tare);
if (balanca.getTareTimeoutFlag()) {
Serial.println("HX711 nao responde, confira ligações");
while (1);
}
else {
balanca.setCalFactor(calibrationValue);
Serial.println("Balanca pronta");
}
balanca.tareNoDelay();
}
//------------------------------------------------------------------------------------------
void loop() {
keyboard();
static boolean newDataReady = 0;
const int serialPrintInterval = 100; //increase value to slow down serial print activity
// check for new data/start next conversion:
if (balanca.update()) newDataReady = true;
// get smoothed value from the dataset:
if (newDataReady)
{
if (millis() > t + serialPrintInterval) {
float i = balanca.getData();
//Serial.print("Load_cell output val: ");
//Serial.println(i);
newDataReady = 0;
t = millis();
display.showNumberDec(i);
}
}
// check if last tare operation is complete
if (balanca.getTareStatus() == true) {
Serial.println("Tare complete");
}
float i = balanca.getData();
}
//-------------------------------------------------------------------------------------------
void keyboard() {
char key = keypad.getKey();
display.showString("A");
if (key) {
int x = key - '0';
display.showNumberDec(x);
Serial.println(x);
}
}
//-------------------------------------------------- END
I have a load cell, Arduino UNO, 4x4 keyboard and TM1637 display - 6 digits.
In loop() I have the weight reading and also the void(keyboard).
Therefore, the display shows flashing values. It's quite annoying to see it blinking. I would like to see both the weight and values typed on the keyboard without blinking.
I already added an integer and did it like this:
if(x == 1) {
keyboard();
}
To only activate this void when it was not showing weight. Ultimately, deactivating one void activates the other. But it did not work.
I would like to see both functions (weight reading and key values) without either of them showing flashing characters on the display.
What would the code for this look like ?
Grateful