I am trying to read a serial string which comes through as "R0123" for example then I need the 0123 to be in an int. to send out through another method
Here is my code it is not working the way that I think it should
void loop()
{
if(Serial.available())
{
delay(100);
if(Serial.read() == 'R')
{
int r1 = Serial.read();
int r2 = Serial.read();
int r3 = Serial.read();
int r4 = Serial.read();
int red = ((int)r1 * 1000) + ((int)r2 * 100) + ((int)r3 * 10) + (int)r4;
sb.sendColour(red,0,0);
Serial.print(r1,0);
Serial.print(r2,0);
Serial.print(r3,0);
Serial.print(r4,0);
Serial.print(red);
}
}
}
`