Scale function in Spin
Arduino has a scale function to scale data
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
How do i do this in spin?
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
How do i do this in spin?

Comments
long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }If you assume that the minimum of the ranges are always 0 then you can simplify:
long map(long x, long in_max, long out_max) { return (x) * (out_max) / (in_max); }pub map(_val,lowIN,highIN,lowOUT,highOUT)|deltaIN,deltaOUT deltaIN := highIN-lowIN deltaOUT := highOUT-lowOUT result := ((deltaOUT * (_val-lowIN)) / deltaIN)+lowOUT