Problem reading random noise generator

Do you know for sure what the map() function actually does, in particular how does it handle numbers that are out of the specified input range? Try some other means of generating the numbers 0-20 from the input. For example, you could try using the remainder function, newnumber = analogRead(inPin)%21;

Edit: here is the actual code for the map function. Clearly, there is a problem using the output as an array index, as the result can go out of the specified output range.

For the mathematically inclined, here's the whole function

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;
}