Hi,
The problem I'm facing is that the user has to input a value trough the serial monitor.
This would be easy if it were only a decimal number they may input.
But they can use a HEX, BIN or DEC value as input.
They would be defined by the commonly used 0x for hex, 0b for bin and nothing for decimal.
After a lot of attempts I came here to ask for some advice, the code you find under here is one of the many attempts (that obviously failed).
Thank you in advanced for helping me.
~TJHUNTER
if(data.charAt(0) == ("0")) {
if(data.charAt(1) == ('b')) {
data.remove(0, 2);
I2C_data[n] = (byte) strtol(data, NULL, 2);
}
else if(data.charAt(1) == ('x')) {
data.remove(0, 2);
I2C_data[n] = (byte) strtol(data, NULL, 16);
}
}
else {
I2C_data[n] = (byte) data.toInt();
}