A handy formula that I usually have to look for when I need it – make a value fall into a specific min-max range. This is the math that gives you a new, scaled up or down, value.
(x - original_min) * (new_max - new_min) / (original_max - original_min) + new_min