I've set up a message system which receives serial data and takes different actions based on the first number in the data.
so "1 hello" prints hello to my LCD - this all works fine.
I want "3 543" to assign 543 to an int. I have managed to chop of the 3 of the string and store the new string as "543" but i'm stuck with how to convert the "543" to an int with the value "543"
This is what i have to chop down the string:
#include <stdio.h>
#include <string.h>
char str1[] = "3 543";
char str2[15];
int i;
int LEDval =0;
void setup()
{
Serial.begin(19200);
for (i=0; str1[i]; i++)
str2[i] = str1[i+2];
str2[i] = '\0';
Serial.println(str2);
}
void loop(){
}
How do i get my int? I'm really confused.
Thanks,
John.