Hello everyone,
First of all, I'm a noob when it comes to coding so please be a bit gentle with me. However, I'm am writing the code for my diy simracing pedals. I'm using the Joystick Library and the hx711 Library. I have to hall effect sensors and one load cell with hx711. With my code the two hall effect sensors are perfectly working but the load cell does not. The wiring is definetely correct.
My code:
#include <HX711.h>
#include <Joystick.h>
Joystick_ Joystick(0x04,JOYSTICK_TYPE_JOYSTICK,
0, 0, // Button Count, Hat Switch Count
false, false, true, // X, Y, Z Axis
true, true, false, // Rx, Ry, Rz Axis
false, false, // rudder, throttle
false, false, false); // accelerator, brake, steering
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 6;
HX711 scale;
void setup() {
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
Joystick.begin(false);
Joystick.setRxAxisRange(-512, 512);
Joystick.setRyAxisRange(-512, 512);
Joystick.setZAxisRange(-512, 512);
}
void loop() {
long reading = scale.read();
int value = map(analogRead(A0) + 0 , 0, 1023, -512, 512) * 1;
Joystick.setRxAxis(value);
value = map(analogRead(A1) + 0 , 0, 1023, -512, 512) *-1;
Joystick.setRyAxis(value);
value = map(reading + 0 , 0, 1023, -512, 512) * -1;
Joystick.setZAxis(value);
Joystick.sendState();
delay (10);
}
This is my previous code and all three pedals work but they have a weird delay to them. ![]()
#include <HX711.h>
#include <Joystick.h>
HX711 scale;
Joystick_ Joystick;
void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
scale.set_scale(-10000);
scale.begin(5,6);
Joystick.begin();
}
void loop() {
Joystick.setRxAxis(analogRead(A0));
Joystick.setRyAxis(analogRead(A1));
Joystick.setZAxis(abs(scale.get_units(1)));
}
Can somebody please help me out?
Greetings