The Joystick data not correct

Hi,
The attached blocks send round data when move the ball2 continually toward one direction, the Arduino HC 05 should receive continuous change data but didn't. why?
Thanks
Adam
joystick.1


data: X/Y

1 Like

Does it work without the if condition ?

3 Likes

Try startX instead of prevX, and startY instead of prevY.

3 Likes

Thank you ABG,
any way to filter the data transferred, or maybe can only do in Arduino receiver side? like average few datas?
also, as I understood, if I drag the ball2 without release until to the edge, there suppose to generate two sets of data: (prevX, prevY) and (currentX, currentY)? in fact I got lot datas, how the datas come out? where to set the frequancy of the data generate?

1 Like

Your subtraction results in overflow for a signed byte value.

Instead of sending round(200-currentX),
set dX = 200-currentX,
if dX < 0 send (-1) * round(log(abs(dX))),
else send round(log(abs(dX)))

This will shrink the range of numbers sent to fit a byte, and smooth it.

1 Like