I need help iam using a joystick and i need to change lateral and forward paratemer according to the angle i got on a joystick

Perhaps these discussions of joysticks in the community will give you some ideas Alex.

https://community.appinventor.mit.edu/search?q=joystick

thnaks Steve i saw them and read them but i couldnt see anything that could give me hint
i just want to change the json value output according to the joystick angle

i can see the blocks but thanks spicy

OK but then you have to share some additional information.

  • what does your json output look like?
  • what does your Blocks look like?
  • Are you using a Bluetooth hardware joystick; do you have documentation showing what it outputs? How are you connecting the Bluetooth. You don't show any code how that is happening.
  • or are you using an Image Sprite to emulate a joystick
  • possibly share your Project aia file

If you can share this type of information then perhaps someone can give you specific advice Alex.

Alex2_1______1.aia (2.9 MB)
my file at the output i only get positive values i nees to get lateral and forward values according to the joystick angle i need to do it using mit inventor only not the arduino code

I haven't any idea . I do have a guess. Perhaps you have to use slider minimum and maximum values?
Set the MinValue ?? of your sliders to get negative values?

Your json strings appear to be valid json strings.

thanks for the response but i dont want to change the code just do what i told you change by the use os the joystick angle

Sorry. Evidently I can not help you. You are not answering questions and not being clear about what you want to do.. You posted your aia with no explanation.

Did you try modifying the sliders as indicated? Modifying the sliders allows you send negative values to the Bluetooth.

?????????

You asked a similar question here Send Json to Arduino (ESP32) serial via Bluetooth (need a little help here please) - #14 by Juan_Antonio , Sorry, the community does not understand what you hope to do. :cry: Perhaps if you draw a picture showing what you want to calculate?

yes i do want to do that the result must be according to the angle of the joystick if i drag towards negative axis i should get the result to my json forward x and lateral y but i dont see how can i do it by using the joystick

like drag the joystick and if its on a negative xy returns tha value to my json forward and lateral i mean - laterl(value) and - forward(value) and viceversa if its posite

iam sorry if iam not clear sometimes

Your Canvas1 only provides positive x,y values. There is no negative axis. See http://www.appinventor.org/bookChapters/chapter17.pdf the section The Canvas Coordinate System.

You seem to expect coordinate system similar to this using the Canvas but the Canvas only provides positive values:
+100
|
|
-180--------------0--------------------+180
|
|
-100

Sorry, that didn't post very well.

Arc drawing example DrawArc Example

Perhaps you could draw a diagram showing how this would work. Post the image If you do that someone could possibly advise on how you could do the required coordinate transformation mathematics?

ok my ideia below

From your diagram I expect you need to convert the Canvas Cartesian coordinates to Polar Coordinates Polar Coordinates (r,ฮธ) from Cartesian Coordinates (x,y)

The mathematics are described here

You would have to use Blocks to do the transformation to Polar and use the Polar values in your json.
You possibly could use javascript to do the transformation javascript cartesian to polar - Google Search

Or you might be able to use this extension [FREE] Maths Extension to convert from cartesian to polar coordinates.

Is that possibly what you want to do?

or perhaps you need to transform the Canvas coordinates to positive and negative values by shifting mathematically the center of the Canvas to a coordinate system with positive and negative values. There is a coordinate 'conversion' algorithm using Blocks described in this AI2 Flat Map Tutorial that could be adapted to your purposes.

I don't quite understand what you are looking for.
You may want to Send Text the x,y values โ€‹โ€‹of the joystick, so in the joystcik.TouchUp block, let
forward = x
lateral = y
SendText

ill do some reseach on that thanks

yes want that but only the signals acording to the angle i need my json to be positive for forward when its on a positive axis just like and for lateral as well yes the x , y signals only the values a may change using the sliders

Let's assume that the left side minimum value is -44 and the right side maximum value is 255, those will be the extreme values โ€‹โ€‹of x.
You want the left side value to be -127 and the right side value to be 127.

-44 ...... 255
-127 ..... 127

Equation of the line.

(X - X1) / (X2 - X1) = (Y -Y1) / (Y2 -Y1)

(X - (-44)) / (255 -(-44)) = ( Y - (-127)) / (127 - (-127))

Y is lateral

y is forward so the car can move
x is lateral so the car can move the axis accordingly
ok thanks ill see how to implement the equation

thanks you