Conversion to a new diapason

Hey, everybody. Tell me how to make it so that inside the MIT Ap Inv number from 0 to 100 (on the canvas ball) was transmitted via bluetooth in the diapozone from 181 to 255, indexed as on the arduino command map(). For example map(x, 0, 100, 181, 255)

valToSend = x * 0.74 + 181

for 0:
0 * 0.74 + 181 = 181
for 100:
100 * 0.74 + 181 = 255

1 Like

Oh, I get it, 5th grade math =) What if the range is from 0 to 200 and we need to turn it into the range 181...255 ?

a = (255 - 181) / (200 - 0)
val = x * a + 181

1 Like

and how will it look in blocks ?

t's basically a constant of 0.37, thank you very much, which direction to go :+1:

I think that mathematical blocks at Appinventor are one of the simplest blocks in use.

map

1 Like

Thank you so much for your help, otherwise I've been puzzling over this task for the third day now :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.