analogRead gives unexpected values


I am trying to send midi messages given by pot connected to A0 with Leonardo.

int val = 0; //Our initial pot value
int lastVal = 0;
#define analogInPin0 A0
void setup()

void loop() {
   val = analogRead(analogInPin0)/8;   // Divide by 8 to get range of 0-127 for midi

   if (val != lastVal) {
   }         // 176 = CC command (channel 1 control change), 1 = Which Control, val = value read from Potentionmeter 1 NOTE THIS SAYS VAL not VA1 (lowercase of course)
   lastVal = val;

void MIDImessage(byte command, byte data1, byte data2) 

When pot is still, it gives correct values. But when I start rotating it, then the output is with some unexpected characters.

Here is output from serial monitor:
Serial monitor output

Can you give me some suggestions what is wrong?

Thank you.

Serial monitor can only handle values between 32 and 127.

Both 176 and 1 are outside that range.
The 2 after the funny character (line 3) is the character 2; the ascii decimal value is 50 (see second line).