string to int (pwm)
i've posted question in software interfacing part, think problem more on arduino hardware/software side.
i try convert string 000 255 value pwm output.
i use method below, other pwm outputs react on changes on output.
maybe code isn't efficient enough.
is there way convert string or hexicadecimal values ( 00-ff ) output value standard arduino library ?
from string int or someting.
i try convert string 000 255 value pwm output.
i use method below, other pwm outputs react on changes on output.
maybe code isn't efficient enough.
is there way convert string or hexicadecimal values ( 00-ff ) output value standard arduino library ?
from string int or someting.
code: [select]
if (serinstring[0]==73) // i
{ (int i=1; <= digseq; i++)
{ if (serinstring[i]==',')
{ p++;
i++;
}
char valchar=serinstring[i];
if(p==8 || p==12 || p==13) // digital outputs
{ // other code
}
else // pwm outputs
{ valpwm = 0;
valpwm = (serinstring[i]-48)*100;
valpwm = valpwm + (serinstring[i+1]-48)*10;
valpwm = valpwm + (serinstring[i+2]-48);
i=i+2;
analogwrite(p,valpwm);
}
}
}
you can use standard c library function atoi(). takes string in decimal , returns integer. checked , adds 120 bytes sketch.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > string to int (pwm)
arduino
Comments
Post a Comment