Scaling a value


Anyone know how to scale a value coming in from serial 0-2000 to 0-255 for use in analog out?

divide it by 8. or shift it right 3 times. byte newValue = analogRead(pinIn) >>3; // pins A0 to A5 analogWrite (pinOut, (newValue)); // pins 3,5,6,9,10,11

Or, use the map() function.

Thanks guys, worked like a charm :)