Correct and smoothest way to convert an char array to a int for PWM-signal


Im sending a char array with RF433.
Buf[0] holds one character representing direction
R = Right,L = Left,F = Forward,B = Back

buf[1] holds analog value from joystick(0-255)
I can receive what i want and values looks ok when i serial.print values but when using analogwrite i dont get any PWM out
Probarly its the way im converting to int… se code below
PWMOut is my PWM-variable

Should i rewrite code totally?

if (vw_get_message(buf, &buflen)) // Non-blocking
int PWMOut = buf[1];
Serial.print(char(buf[0])); // Print the correct direction
Serial.println(PWMOut); // Prints the correct analogvalue
if (buf[0]==‘R’)
Serial.println("Right ");
analogWrite(LEFTFORWARD, 0);
analogWrite(RIGHTREVERSE, 0);
// no action on pwmpins, measured with oscilloscope. When i enter a number instead of PWMOut i get a pwmsignal
analogWrite(LEFTREVERSE, PWMOut);
analogWrite(RIGHTFORWARD, PWMOut);
driveTimeout = millis() + DRIVETIME;

We have no idea what is sending data to this snippet. We have no idea what all the variable types are. We can not help you without seeing ALL of your code.

There isn't even any proof that you are using a PWM pin.

There are so many potential problems that could stop this working, that it's pointless guessing until you show us a complete sketch. As a trivial example, we have no idea whether you're using an analog-capable pin and have configured it as an output.