Hello goan,
analogWrite puts PWMpin into a PWM mode. digitalWrite will not work on that mode, thus, before use it you must set up PWMpin as output. I am not sure if the Arduino team is working on this. Regards!
case 'i':
analogWrite(PWMpin, 127);
break;
case 'o':
pinMode(PWMpin,OUTPUT);
digitalWrite(PWMpin, LOW);
break;