convert string of bytes to int

I am sending my arduino serial data and I am adding the bytes to an array, ultimately I would like to get this string of values into a single integer. say Ive got an array that is [2, 2, 0] … I need to get this to be 220 as an int

I found Tom Igoes example for “web scraping” … and its very similar to how I was approaching it, thought it was all I needed … http://www.tigoe.net/pcomp/code/archives/arduino/000761.shtml … here he is using

From Igoe

if (status == reading) {
if (Serial.available()) {
inByte = Serial.read();
// Keep reading until you get a “>”:
if (inByte != 62) {
// save only ASCII numeric characters:
if ((inByte >= 48) && (inByte <= 57)){
inString[stringPos] = inByte;
stringPos++;
}
}
else {
// convert the string to a numeric value:
int airQuality = stringToNumber(inString, stringPos);
// set the meter appropriately:
setMeter(airQuality);
status = disconnected;

From what I can tell it looks like this method stringToNumber(), is exactly what I need but when I try to implement At compile, Im told the function is not declared, which I am assuming is because its not part of 007 … a browse through the class reference from processing doesn’t turn it up either, but it does turn up parseInt() which seems to be the same functionality, only to get the same error.

So I am wondering if I am missing a library, or if I am just doing something wrong? I didtn see any includes in Igoes app?

my code

void simocc() {
while (Serial.available() > 0) {
//read incoming byte
incomingByte = Serial.read();// store first byte in temp 1
//if incoming byte is “A”
if (incomingByte == 65) {
//read next byte and store it in incomingID
incomingID = Serial.read();// store second byte in temp 2
//read next 3 bytes and stroe in the buffer
incomingString[0] = Serial.read();// store first byte of value in string
incomingString[1] = Serial.read();// store second byte of value in string
incomingString[2] = Serial.read();// store third byte of value in string
//convert buffer to usable integer
lengthofdelay = stringToNumber(incomingString);//to be replaced with simocc_parse();
}
} // end while

Serial.flush();// flush serial
}

Of course any suggestions for a better process are much appreciated. I am using the CSerial library to send the data from a win32 app, need to be able to periodically send the arduino a series of value pairs (Value ID (single byte is fine), value (prefer unlimited bytes but could limit if necessary). Thanks for the help

parseInt() is a Java function, which isn't available in C/C++ which Arduino uses. You can try atoi(), which is the C equivalent. You'll need to make sure there's a zero byte at the end of your array of characters, (e.g. incomingString[3] = 0; ). Then just call lengthofdelay = atoi(incomingString); .