<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to convert arduino code to mbed online compiler using nRF51822 ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33396/how-to-convert-arduino-code-to-mbed-online-compiler-using-nrf51822</link><description>Hello world. 
 I wanna ask about how to convert arduino code possible for mbed compiler for arduino. first of all, I have tried to use this guy program knn arduino code .. 
 this is the general code from him.. 
 
 in arduino looks like this one.. 
 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Apr 2018 08:42:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33396/how-to-convert-arduino-code-to-mbed-online-compiler-using-nrf51822" /><item><title>RE: How to convert arduino code to mbed online compiler using nRF51822 ?</title><link>https://devzone.nordicsemi.com/thread/128747?ContentTypeID=1</link><pubDate>Wed, 18 Apr 2018 08:42:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df7d40e0-f492-4bed-8f6c-05583b47bc55</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It means that the function named millis() is not found anywhere. Perhaps because of a missing header file. &lt;a href="https://www.google.com/search?q=millis"&gt;A quick google search&lt;/a&gt; reveals that &lt;a href="https://www.arduino.cc/reference/en/language/functions/time/millis/"&gt;it is a standard library function for Arduino&lt;/a&gt;. You should see if you find a &lt;a href="https://www.google.com/search?q=millis+equivalent+mbed"&gt;similar function in mbed&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert arduino code to mbed online compiler using nRF51822 ?</title><link>https://devzone.nordicsemi.com/thread/128655?ContentTypeID=1</link><pubDate>Tue, 17 Apr 2018 14:25:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3bc8976-7ef2-42a0-b435-9323aef74f9a</guid><dc:creator>mantap</dc:creator><description>&lt;p&gt;after several hours, there was an answer from another forum that says like &lt;a href="https://os.mbed.com/questions/80921/How-to-convert-arduino-code-to-mbed-onli/" rel="noopener noreferrer" target="_blank"&gt;this&lt;/a&gt;..&lt;/p&gt;
&lt;p&gt;I have try to modify the &lt;strong&gt;extraeDatos&lt;/strong&gt; function as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void extraeDatos(string&amp;amp; str, double dato[], char dlm[])
{
    string  auxstr = &amp;quot;&amp;quot;;
    int     posdlm[5], tamstr = 0;
    int     i = 0, j = 0;
 
    // buscar caracteres de identificacion  / Identification of characters
    posdlm[0] = str.find(dlm[0], 0);             // (
    posdlm[1] = str.find(dlm[1], posdlm[0]);     // ,
    posdlm[2] = str.find(dlm[1], posdlm[1] + 1); // ,
    posdlm[3] = str.find(dlm[1], posdlm[2] + 1); // ,
    posdlm[4] = str.find(dlm[2], posdlm[3]);     // )
    for (j = 0; j &amp;lt; co; j++)
    {
        // extraer datos numericos / Extract numerical data
        for (i = posdlm[j] + 1; i &amp;lt; posdlm[j + 1]; i++)
        {
            auxstr = auxstr + str[i];
        }
 
        //convertir a double / Convert to double
        //int     y = auxstr.length();
        //char    buf[y + 1];
        //auxstr.c_str(buf, y + 1);
        dato[j] = atof(auxstr.c_str());
 
        //printf(dato[j],3);
        auxstr = &amp;quot;&amp;quot;;                                // reset del auxiliar
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;but I have several error message that code not completed clear, because this code..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while(1) 
    {
  
        // recibir los datos a clasificar
        if(Serial.available())
        {
       
            // recibir una cadena hasta que se tenga el &amp;#39;\n&amp;#39;
            string str = Serial.readStringUntil(&amp;#39;\n&amp;#39;);  
            extraeDatos(str, dato, &amp;quot;{,}&amp;quot;);
    
            // tic
            previo = millis();    
          
            // encontrar la clase, con 5 vecinos cercanos
            int cl = clasificaKNN((double**)atributos, clasesNo, dato, 11, FI, CO);
            pc.printf(&amp;quot;%i\n&amp;quot;,(int16_t)cl);
 
            // tac
            actual = millis();
  
            // imprimir
            imprime(dato, cl);
            pc.printf(&amp;quot;Tiempo: &amp;quot;); pc.printf(&amp;quot;%i\n&amp;quot;,(int16_t)actual-previo); pc.printf(&amp;quot; mS\n&amp;quot;);
        }
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;that&amp;#39;s show error like this one..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Error: Expected a declarator in condition declaration in &amp;quot;main.cpp&amp;quot;, Line: 85, Col: 19
Error: Type name is not allowed in &amp;quot;main.cpp&amp;quot;, Line: 89, Col: 27
Error: Identifier &amp;quot;millis&amp;quot; is undefined in &amp;quot;main.cpp&amp;quot;, Line: 93, Col: 23&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4011.Untitled2.png" /&gt;&lt;/p&gt;
&lt;p&gt;please give me best solution to solve that problem..&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert arduino code to mbed online compiler using nRF51822 ?</title><link>https://devzone.nordicsemi.com/thread/128516?ContentTypeID=1</link><pubDate>Mon, 16 Apr 2018 15:37:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:685c667b-83e9-494d-bfd0-2dcf8c01dcbf</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately I do not think I am able to help you with the mbed part of this, but perhaps others on this forum can?&lt;/p&gt;
&lt;p&gt;In any case, I still think you will have better luck if you state your problem on the mbed forums. There are a lot of people there that knows a lot about both mbed and nRF51, and because of that we always recommend to ask the mbed related questions there.&lt;/p&gt;
&lt;p&gt;If you are looking for a &lt;a href="https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm"&gt;k-nearest neighbors algorithm&lt;/a&gt; implementation for mbed, you might be able to find that directly instead of having to port an arduino project?&lt;/p&gt;
&lt;p&gt;Regarding the arduino project that you were linking to: I am not convinced that it is a good library. It has variable names and comments in a language that I do not understand, but it does look unfinished and not very well tested. The few translations to English are poor. The project has not been updated after the initial commit three years ago... Finding another implementation (or even implementing an algorithm yourself) may be better.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert arduino code to mbed online compiler using nRF51822 ?</title><link>https://devzone.nordicsemi.com/thread/128504?ContentTypeID=1</link><pubDate>Mon, 16 Apr 2018 14:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31e77369-98f4-4134-ab0d-171205f9c26b</guid><dc:creator>mantap</dc:creator><description>&lt;p&gt;thanks for answering before, I&amp;#39;m using nRF51822 core board. Because my first implement before from mbed compiler so I think it&amp;#39;s easier to continue that program using mbed but That are several error that must be solve.. if your kindness help me to solve the problem that I explained before it is so much pleasure..&lt;br /&gt;&lt;br /&gt;because it&amp;#39;s my progress and I&amp;#39;m newbie from this program c++. so please help me to solve it using mbed compiler please..&lt;br /&gt;many thanks if you can help me..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert arduino code to mbed online compiler using nRF51822 ?</title><link>https://devzone.nordicsemi.com/thread/128501?ContentTypeID=1</link><pubDate>Mon, 16 Apr 2018 14:06:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8db9033-afc3-41fa-be90-20d9952b63be</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What board (and microcontroller) are you developing for?&lt;/p&gt;
&lt;p&gt;Correct me if I am wrong, but from what I can see that github project is made for an arduino board which does not use any product from Nordic Semiconductor. If you use an nRF51 SoC from us, then it is probably better to have a look at our &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.3.0%2Findex.html"&gt;nRF5 SDK v12.3.0&lt;/a&gt;, which is our latest SDK supporting the nRF51 series.&lt;/p&gt;
&lt;p&gt;In any case: If porting that code from arduino to mbed is what you really want then you may have better luck if you ask those questions on the mbed and/or arduino forums instead.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>