[Solved]
i'm making project allows rgb led controlled through serial using c# program have written.
this , example of string sending arduino c# app: 064,128,255
i use wrote code store in buffer read whole.
it returns stored array of chars received through serial port.
but need write method can take buffer, split substrings (rgb values extracted) , use them pwm value.
is able me this, i've searched lot didn't find , i'm not acquainted pointers think plays part.
any appreciated
this , example of string sending arduino c# app: 064,128,255
i use wrote code store in buffer read whole.
code: [select]
char* getstringfromserialdata()
{
char charbuffer[11];
char newchar;
int index = 0;
while (serial.available() > 0)
{
if (index < 10)
{
newchar = serial.read();
charbuffer[index] = newchar;
index++;
charbuffer[index] = '\0';
}
}
return charbuffer;
}it returns stored array of chars received through serial port.
but need write method can take buffer, split substrings (rgb values extracted) , use them pwm value.
is able me this, i've searched lot didn't find , i'm not acquainted pointers think plays part.
any appreciated

one thing need careful charbuffer local variable. goes out of scope when getstringfromserialdata() function ends. returning pointer space no longer exist.
for time being, should make charbuffer global variable, , make getstringfromserialdata() void function.
as parsing string, haven't given go on. have no idea delimiters, if any, using.
the strtok function can extract token string, when delimiters known.
for time being, should make charbuffer global variable, , make getstringfromserialdata() void function.
as parsing string, haven't given go on. have no idea delimiters, if any, using.
the strtok function can extract token string, when delimiters known.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > [Solved]
arduino
Comments
Post a Comment