The code below shows how to convert int to char array in Arduino and how to convert char array to int.
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// send an intro:
Serial.println("\n\nString Constructors:");
Serial.println();
}
String str;
int num = 0;
int num2 = 0;
char cstr[16];
void loop() {
// int to char array
delay(200);
num++;
str = String(num);
str.toCharArray(cstr,16);
Serial.println(cstr); // prints "Hello String"
//char array to int
num2 = atoi(cstr);
num2++;
Serial.println(num2);
}