I m trying to make a brake pedal for simracing using a 20kg loadcell and the HX711 and a promicro , i only have 1 loadcell . i managed to get the promicro recognized as a HID controller device in windows with axis that move when i put weight on the loadcell however , the axis ( and the numbers on serial monitor ) are showing very delayed results .
this is a video i made showing the problem : https://youtu.be/gcctvu708Dc
this is my HX711 :
and this is my code ( half of which i copy pasted from the read1 value example of the HX711_ADC library ) :
#include <HX711_ADC.h>
#include <EEPROM.h>
#include <Joystick.h>
HX711_ADC LoadCell(4, 8); // HX711 DOUT , SCK PINS
int loadvalue =0; // RAW value of loadcell after calibration ( in grams )
const int calVal_eepromAdress = 0; // calibration value memory address in the eeprom ( i think )
int brake; // braking value mapped and sent to the controller axis
int throttle; // throttle value mapped and sent to the controller axis
int clutch; // clutch value mapped and sent to the controller axis
int maxbrakepressure = 6000; // maximum value read after calibration OR maximum braking load ( test which is higher )
//create the controller
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
0, 0, // Button Count, Hat Switch Count
false, false, true, // No X and Y, but Z Axis
false, false, false, // No Rx, Ry, or Rz
false, true, // No rudder, but throttle
false, true, false); // No accelerator , brake on , no steering
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
LoadCell.begin(); //sets pins connected to load cell amplifier ( HX711 ) and starts the load cell
float calibrationValue; // calibration value
EEPROM.get(calVal_eepromAdress, calibrationValue); // getting calibration value from EEPROM
unsigned long stabilizingtime = 3000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed at startup
LoadCell.start(stabilizingtime, _tare);
LoadCell.setCalFactor(calibrationValue);
Joystick.begin(true);
}
void loop(){
if (LoadCell.update()){
loadvalue = LoadCell.getData();
brake=map(loadvalue, 0 , maxbrakepressure , 0 , 1023);
Joystick.setThrottle(brake);
}
Serial.println(brake);
// receive command from serial terminal, send 't' to initiate tare operation:
if (Serial.available() > 0) {
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
}

