<?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>Problem with ADC result.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43630/problem-with-adc-result</link><description>Hello, 
 So I&amp;#39;m using nrf52832 with sdk15.2 and I&amp;#39;m trying to connect a joystick to the adc pins and have the joystick to move the mouse instead of the buttons and having issues with that. I have successfully combined both SAADC and BLE_HIDS_MOUSE examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Feb 2019 07:14:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43630/problem-with-adc-result" /><item><title>RE: Problem with ADC result.</title><link>https://devzone.nordicsemi.com/thread/171017?ContentTypeID=1</link><pubDate>Thu, 14 Feb 2019 07:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2e43c48-a4bb-43f5-85b8-a01766516d13</guid><dc:creator>Maher Shakir</dc:creator><description>&lt;p&gt;It worked. your suggestion was the solution to my problem.&lt;/p&gt;
&lt;p&gt;Much appreciated Edvin,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with ADC result.</title><link>https://devzone.nordicsemi.com/thread/170929?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 14:36:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65498fd9-457e-43a4-8a5f-da868b66b150</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;A few comments to your code. You may already be aware of this, but I want to check.&lt;/p&gt;
&lt;p&gt;This part in the end of your main() before the loop main-loop.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// TEST
         while  (ADC_North &amp;gt; 10)
         {
            if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
            {
                mouse_movement_send(-MOVEMENT_SPEED, 0);
            }
            }
// END TEST&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Will not do anything, because you probably haven&amp;#39;t received any saadc callbacks yet, so your ADC_North is probably still 0.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I see in your saadc callback function, you call the mouse_movement_send() function, and you don&amp;#39;t use the global variables, ADC_North, west, ...&lt;/p&gt;
&lt;p&gt;Also, I see that you have two while loops in main. Reduce this to one.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But can you try to do the following instead of your while loops in this function:&lt;/p&gt;
&lt;p&gt;ADC_North =&amp;nbsp; p_event-&amp;gt;data.done.p_buffer[0];&lt;/p&gt;
&lt;p&gt;as you already have. Skip all while loops and their content in this function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then add the following in your main-loop (the one containing idle_state_handle(). The other one is never reached)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;for (;;)
{
    run_mouse();
    idle_state_handle();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then add this function something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static run_mouse(void)
{
    if(ADC_North &amp;gt; 10)
    {
        mouse_movement_send(-MOVEMENT_SPEED, 0);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If this doesn&amp;#39;t work, I see that you don&amp;#39;t check your return values. Try to print their values to see what they return.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>