I am trying ... with minimal success to change/Check and also run voids through the serial monitor .the code i put i am having probles is that when i am try to send a value larger than 9 the value assigns a diffrent number Ex i set to 200 but arduino sets it as 512.. i got around it deviding the value by 1.6 and got me the new number and only works upto 90 , but i am tryn to see how it should be done correctly...
const uint16_t inputLength = 512;
int ss = 0;
int bHold = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if ( Serial.available() > 0 )
{
static char input[inputLength];
static uint16_t i;
char c = Serial.read();
if ( c != '\r' && c != '\n' && i < inputLength - 1)
input[i++] = c;
else
{
input[i] = '\0';
i = 0;
uint16_t array[80];
uint16_t j = 0;
if ( !strncmp(input, "ss", 2) )
{
char* p = input + 2;
while ( (p = strchr(p, ' ')) != NULL )
array[j++] = strtol(p, &p, 10); //< changed from 16
for ( uint8_t i = 0; i < j; i++ )
{
ss = array[i];
Serial.println(ss);
}
}
if ( !strncmp(input, "bHold", 5) )
{
char* p = input + 5;
while ( (p = strchr(p, ' ')) != NULL )
array[j++] = strtol(p, &p, 10); //< changed from 16
for ( uint8_t i = 0; i < j; i++ )
{
bHold = array[i];
// bHold=bHold /1.6;
Serial.println(bHold);
}
}
if ( !strncmp(input, "Whos There", 10) )
{
Serial.print("me");
}
if ( !strncmp(input, "hello", 5) )
{
Serial.print("hi");
}
if ( !strncmp(input, "sa", 2) )
{
Serial.print(" ss= ");
Serial.print(ss);
Serial.print(" bHold= ");
Serial.print(bHold);
Serial.println(" ");
Serial.println("==============================");
}
}
}
}
Thank you for any tips you can give...
EDIT: I am trying to pass a new value with command on the serial monitor "ss 500"..so that in the arsuino ss = 500. but in this case it makes it equal to 1280.
EDIT2: Chaged the strol to 10...works perfectly ...Thank you TisteAndii!!!!