Have you tried:- val = map(val, 0, 1023, 179, 0);
Don't know if it will work.
If not just use:- val = 179 - val