Tried to change as advised - problem still exists ...:
/*
*
* Siehe Arduino Cookbook: safari books online
* Sends station numbers to Raspberri: ok
* Receives max Numb of stations from Raspberry: nok
*/
const int MaxChars = 2;
char strValue[MaxChars+1];
int index = 0;
int maxNumb = 26 ;
int value;
int upperValue;
int lowerValue;
char ch;
int poti = 0;
int sensorValue;
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
}
void loop() // run over and over again
{
do
{
sensorValue = analogRead(poti);
int upperValue = sensorValue + 2;
int lowerValue = sensorValue - 2;
} while (sensorValue < upperValue && sensorValue > lowerValue);
int tunerValue = map(sensorValue, 0, 1023, 1, maxNumb);
if (tunerValue < 10)
{
Serial.print(0);
}
Serial.println(tunerValue,DEC);
delay(250);
if (Serial.available())
{
char ch = Serial.read();
if(index < MaxChars && ch >= '0' && ch <= '9'){
strValue[index++] = ch; // add the ASCII character to the string;
}
else
{
// here when buffer full or on the first non digit
strValue[index] = 0; // terminate the string with a 0
maxNumb = atoi(strValue); // use atoi to convert the string to an int
index = 0;
}
}
}