calling an "int" makes thing go slooowwww...

so, before i start... please forgive me if the answer is obvious lol.

i have written this little script to read a load-cell (hx711) and use its values to output to a pwm pin.

the load cell is attached to a sim racing brake pedal, and the pwm pin is connected to the analogue signal line that the original potentiometer was connected too via a simple DAC.

now, here is the boggle...

im trying to take the first reading (with no load on the pedal) and use it as a sort of calibration value. however, when i call the stored value it seems to change how it works....

this work fine... i can connect to the wheel base and everything work perfect.

input = (hx711.read() / 1);

int pressureAdj = analogRead(A5); int long pressureVar = map(pressureAdj, 0, 800, 16777777, 13000000);

input = constrain(input, 10850000, pressureVar); output = map (input, 10850000, pressureVar, 0, 245);

analogWrite(6, output);

for some reason though, this does not... with this code, the serial monitor shows everything to be perfect and as i would expect.

int long cal =0;

if (cal == 0){ cal = (hx711.read() / 1);

}

input = (hx711.read() / 1);

int pressureAdj = analogRead(A5); int long pressureVar = map(pressureAdj, 0, 700, 16777777, 13000000);

input = constrain(input, cal, pressureVar); output = map (input, cal, pressureVar, 0, 245);

analogWrite(6, output);

but from pin 6 it takes longer for voltage to output. when the voltage is there it is still very responsive to physical input... it just seems like i have to push the pedal harder for it to work.

This: int long pressureVar = map(pressureAdj, 0, 700, 16777777, 13000000); is not correct. "int long" !!!

right enough, thats what i get for writing this from memory lol

knut_ny: int long pressureVar = map(pressureAdj, 0, 700, 16777777, 13000000); is not correct. "int long" !!!

True. It should be "long int".

jaikai2009: right enough, thats what i get for writing this from memory lol

OK, so the code you typed above (and you forgot to place between code tags) is not your actual code, and therefore useless for us. Don't do that. You're wasting our time offering FREE help. Copy your ACTUAL code from the IDE (it even has a "copy for forum" function for this in the Edit menu, conveniently adding code tags!) and post it.