Hello
Im trying to get this multi load cell to work. I can get the values from the array in serial monitor but i cant get the axis to move.
I have checked the other inputs and i get values there too but where [0] starts around -42 [1] starts around 256. i find that a bit odd // ignore this in your answer, its just fiy. I also have it working with one in the standard HX711 lib
I need to divide it with 800 to get a much smaller number.
Any ides's on how to get this to work. Please be very specific as im a noob
Thank you
part code:
//throttle = results[0] / 8 ;
Serial.println(throttle);
//Joystick.setThrottle(digitalRead(throttle));
//delay(1);
throttle = -results[0] / 800 ;
Joystick.setBrake(digitalRead(throttle)); // why wont this register in the axis?
delay(1);
// Joystick.setZAxis(analogRead(clutch));
// delay(1);
Full code
/*#include <HX711.h>
#define calibration_factor -640.0 // Do your calibration first.
#define DOUT 3
#define CLK 2
*/
#include <Joystick.h>
#include "HX711-multi.h"
// Pins to the load cell amp
#define CLK 2 // clock pin to the load cell amp
#define DOUT1 3 // data pin to the first lca
#define DOUT2 4 // data pin to the second lca
#define DOUT3 5 // data pin to the third lca
#define TARE_TIMEOUT_SECONDS 4
byte DOUTS[3] = {DOUT1, DOUT2, DOUT3};
#define CHANNEL_COUNT sizeof(DOUTS)/sizeof(byte)
long int results[CHANNEL_COUNT];
HX711MULTI scales(CHANNEL_COUNT, DOUTS, CLK);
// HX711 scale;
/*
For the true false flags, use this list. Its all in Joystick.h
bool includeXAxis = true,
bool includeYAxis = true,
bool includeZAxis = true,
bool includeRxAxis = true,
bool includeRyAxis = true,
bool includeRzAxis = true,
bool includeRudder = true,
bool includeThrottle = true,
bool includeAccelerator = true,
bool includeBrake = true,
bool includeSteering = true);
*/
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_MULTI_AXIS, 4, 3,
false, false, false, false, false, false,
false, false, true, true, false);
// Variable
int throttle = 0;
int brake = 0;
int clutch = 0;
// init joystick libary
void setup() {
// Ranges are 1023 by default
// Joystick.setBrakeRange(-300, 10230);
//Joystick.setThrottleRange(0, 1023);
//Joystick.setZAxisRange(0, 255);
Joystick.begin();
Serial.begin(115200);
Serial.flush();
pinMode(11,OUTPUT);
tare();
}
void tare() {
bool tareSuccessful = false;
unsigned long tareStartTime = millis();
while (!tareSuccessful && millis()<(tareStartTime+TARE_TIMEOUT_SECONDS*1000)) {
tareSuccessful = scales.tare(20,10000); //reject 'tare' if still ringing
}
}
void sendRawData() {
scales.read(results);
for (int i=0; i<scales.get_count(); ++i) {;
// Serial.print( -results[i]);
// Serial.print( (i!=scales.get_count()-1)?"\t":"\n");
}
delay(10);
}
void loop() {
sendRawData(); //this is for sending raw data, for where everything else is done in processing
//on serial data (any data) re-tare
if (Serial.available()>0) {
while (Serial.available()) {
Serial.read();
}
tare();
}
//throttle = results[0] / 8 ;
Serial.println(throttle);
//Joystick.setThrottle(digitalRead(throttle));
//delay(1);
throttle = -results[0] / 800 ;
Joystick.setBrake(digitalRead(throttle)); // why wont this register in the axis?
delay(1);
// Joystick.setZAxis(analogRead(clutch));
// delay(1);
}