Not able to fill int with char

I have a few code lines that fill an int using a char. I know it's obvious that will cause issues but I don't know how to convert it properly. The data that's coming to the Arduino will always come as a number.

if (radio.available())              
char text[32] = "";        , sizeof(text));    
throttleIN = text;

Error I get:

/home/linux/Desktop/Rockets/Rocket_Code_PA_MIN/Rocket_Code_PA_MIN.ino: In function 'void loop()':
/home/linux/Desktop/Rockets/Rocket_Code_PA_MIN/Rocket_Code_PA_MIN.ino:26:14: warning: invalid conversion from 'char*' to 'int' [-fpermissive]
 throttleIN = text;

A single digit? Or a string of digits (12345)?

BTW.. please post all code in code tags (</>).

It will come as a number that can range from 0 to 255

Sorry, didn't know that


char array [5] = "123";

int x = 0;
int z = 0;

void setup()
  Serial.begin (9600);

  x = atoi(array);
  z = x * 100;

  Serial.println (x);
  Serial.println (z);

void loop()

1 Like

No errors seen!!!

Thanks a lot!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.