Serial Arduino com

Hi guys!

I triying to make a simple comunication Arduino<–>OF

I would like to send an identifier and data to Arduino
send for example ‘a’ to recieve analogRead from the Arduino
and ‘b’ to change the PWM (int) value in one of the Arduino PWM pins.

something like this:

serial.writeByte(‘b’);
serial.writebytes(valuePWM);

(I know this is wrong… just get the idea)

in the other hand the arduino will have something like this:

  
  
ID = serial.read()  
switch (ID){  
      case 'a':  
        Serial.print(analogRead(A0));          
        break;  
      case 'b':  
        Serial.read();  
        int pwm = map(Serial.read(),0,100,0,255);    
    }  
  
  
}  
  

I know this is all wrong so think it as an idea…

How can I send those ID and string (or Int) to an Arduino? I can’t use firmata…