Variável numérica para texto [RESOLVIDO] - Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)2024-03-29T10:53:34Zhttps://labdegaragem.com/forum/topics/vari-vel-num-rica-para-texto?feed=yes&xn_auth=noObrigado a TDS que colaborara…tag:labdegaragem.com,2020-10-09:6223006:Comment:7562732020-10-09T02:30:16.664ZCesar Luishttps://labdegaragem.com/profile/cesarluis
<p>Obrigado a TDS que colaboraram.. entendi as colocações, e em breve vou utilizar este recurso p aprender algo a mais.. no momento consegui o meu objetivo usando diretamente uma variável numérica que antes não funcionava .. consegui um atalho.. </p>
<p>Obrigado a TDS que colaboraram.. entendi as colocações, e em breve vou utilizar este recurso p aprender algo a mais.. no momento consegui o meu objetivo usando diretamente uma variável numérica que antes não funcionava .. consegui um atalho.. </p> Use a função:
char *dtostrf (…tag:labdegaragem.com,2020-10-09:6223006:Comment:7561572020-10-09T01:31:36.613ZCurti Esse Lado Seu Otimistahttps://labdegaragem.com/profile/eijuito
<p>Use a função:</p>
<pre><code>char *dtostrf ( double val , signed char width , unsigned char prec , char *s )</code><br/>Exemplo:</pre>
<pre><code>char str_temp[6] ;<br/>dtostrf( temp , 4 , 2 , str_temp ) ;<br/>sprintf( temperature , "%s F" , str_temp ) ;<br/>Boa sorte.</code></pre>
<p>Use a função:</p>
<pre><code>char *dtostrf ( double val , signed char width , unsigned char prec , char *s )</code><br/>Exemplo:</pre>
<pre><code>char str_temp[6] ;<br/>dtostrf( temp , 4 , 2 , str_temp ) ;<br/>sprintf( temperature , "%s F" , str_temp ) ;<br/>Boa sorte.</code></pre> use a função abaixo:
char *dt…tag:labdegaragem.com,2020-10-08:6223006:Comment:7559182020-10-08T16:47:26.106ZRodrigo Corberahttps://labdegaragem.com/profile/RodrigoCorbera
<p>use a função abaixo:<br></br><br></br></p>
<pre style="margin: 0; padding: 0;"><code class="bbc_code" style="max-height: none; height: auto;">char <span style="white-space: pre;">*</span>dtostrf (double __val, signed char __width, unsigned char __prec, char *__s)</code>;<br></br><br></br>no seu caso será algo como<br></br>char strBuffer[11]; // 10 caracteres 'nn.ddddddd' mais o '\0' terminador de string<br></br>float floatVar = 12.1234567; // exemplo de float para converter<br></br>dtostrf(floatVar, 10, 7, strBuffer);…</pre>
<p>use a função abaixo:<br/><br/></p>
<pre style="margin: 0; padding: 0;"><code class="bbc_code" style="max-height: none; height: auto;">char <span style="white-space: pre;">*</span>dtostrf (double __val, signed char __width, unsigned char __prec, char *__s)</code>;<br/><br/>no seu caso será algo como<br/>char strBuffer[11]; // 10 caracteres 'nn.ddddddd' mais o '\0' terminador de string<br/>float floatVar = 12.1234567; // exemplo de float para converter<br/>dtostrf(floatVar, 10, 7, strBuffer); // converte em strBuffer</pre>
<p>println(strBuffer); // mostra o resultado como uma string</p>
<p><br/><a href="https://forum.arduino.cc/index.php?topic=243660.0" target="_blank">https://forum.arduino.cc/index.php?topic=243660.0</a></p>