AilgorRC : My first RC car with IOIO + L293D

I am novice in Java, IOIO and Robotic.

This is my First Robot : A car RC with IOIO-OTG Board and L293d to drive Motors

Platform :

  • IOIO-OTG
  • Bridge H : L293D
  • 2 motors DC 6V
  • Charger Module LiPo Pro POW12059P
  • Accu Li-Ion 3,7 V 2000 mAh

Schema

 

 

And the code : https://github.com/ailgorbot/AilgorRC

4 buttons (left, right, up, down) to create in MainActivity (see file AndroidManifest.xml in GitHub)

 

package fr.ailgor.ailgorrc;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.widget.ToggleButton; import ioio.lib.api.DigitalOutput;
import ioio.lib.api.PwmOutput;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.util.BaseIOIOLooper;
import ioio.lib.util.IOIOLooper;
import ioio.lib.util.android.IOIOActivity; public class MainActivity extends IOIOActivity {
</span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">ToggleButton</span><span class="pln"> toggleButtonLedSTAT</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="typ" style="color: #660066;">Button</span><span class="pln"> buttonLeft</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="typ" style="color: #660066;">Button</span><span class="pln"> buttonRight</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="typ" style="color: #660066;">Button</span><span class="pln"> buttonUp</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="typ" style="color: #660066;">Button</span><span class="pln"> buttonDown</span><span class="pun" style="color: #666600;">;</span><span class="pln">


</span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> motorLeft</span><span class="pun" style="color: #666600;">=</span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> motorRight</span><span class="pun" style="color: #666600;">=</span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="kwd" style="color: #000088;">float</span><span class="pln"> speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="lit" style="color: #006666;">0</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
</span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="kwd" style="color: #000088;">void</span><span class="pln"> onCreate</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">Bundle</span><span class="pln"> savedInstanceState</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">super</span><span class="pun" style="color: #666600;">.</span><span class="pln">onCreate</span><span class="pun" style="color: #666600;">(</span><span class="pln">savedInstanceState</span><span class="pun" style="color: #666600;">);</span><span class="pln">
    setContentView</span><span class="pun" style="color: #666600;">(</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">layout</span><span class="pun" style="color: #666600;">.</span><span class="pln">activity_main</span><span class="pun" style="color: #666600;">);</span><span class="pln">

    toggleButtonLedSTAT </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">ToggleButton</span><span class="pun" style="color: #666600;">)</span><span class="pln">findViewById</span><span class="pun" style="color: #666600;">(</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">id</span><span class="pun" style="color: #666600;">.</span><span class="pln">toggleButtonLedSTAT</span><span class="pun" style="color: #666600;">);</span><span class="pln">

    buttonLeft </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">Button</span><span class="pun" style="color: #666600;">)</span><span class="pln"> findViewById</span><span class="pun" style="color: #666600;">((</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">id</span><span class="pun" style="color: #666600;">.</span><span class="pln">buttonLeft</span><span class="pun" style="color: #666600;">));</span><span class="pln">
    buttonRight </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">Button</span><span class="pun" style="color: #666600;">)</span><span class="pln"> findViewById</span><span class="pun" style="color: #666600;">((</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">id</span><span class="pun" style="color: #666600;">.</span><span class="pln">buttonRight</span><span class="pun" style="color: #666600;">));</span><span class="pln">
    buttonUp </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">Button</span><span class="pun" style="color: #666600;">)</span><span class="pln"> findViewById</span><span class="pun" style="color: #666600;">((</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">id</span><span class="pun" style="color: #666600;">.</span><span class="pln">buttonUp</span><span class="pun" style="color: #666600;">));</span><span class="pln">
    buttonDown </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">Button</span><span class="pun" style="color: #666600;">)</span><span class="pln"> findViewById</span><span class="pun" style="color: #666600;">((</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">id</span><span class="pun" style="color: #666600;">.</span><span class="pln">buttonDown</span><span class="pun" style="color: #666600;">));</span><span class="pln">

    enableUi</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">);</span><span class="pln">

    buttonLeft</span><span class="pun" style="color: #666600;">.</span><span class="pln">setOnTouchListener</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">new</span><span class="pln"> </span><span class="typ" style="color: #660066;">View</span><span class="pun" style="color: #666600;">.</span><span class="typ" style="color: #660066;">OnTouchListener</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
        </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
        </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> onTouch</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">View</span><span class="pln"> v</span><span class="pun" style="color: #666600;">,</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pln"> </span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">if</span><span class="pln"> </span><span class="pun" style="color: #666600;">((</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getAction</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">==</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_MOVE</span><span class="pun" style="color: #666600;">)||(</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getActionMasked</span><span class="pun" style="color: #666600;">()!=</span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_UP</span><span class="pun" style="color: #666600;">))</span><span class="pln">
            </span><span class="pun" style="color: #666600;">{</span><span class="pln">
                motorLeft </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                motorRight </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">float</span><span class="pun" style="color: #666600;">)</span><span class="lit" style="color: #006666;">0.5</span><span class="pun" style="color: #666600;">;</span><span class="pln">
            </span><span class="pun" style="color: #666600;">}</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">else</span><span class="pln">
            speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="lit" style="color: #006666;">0</span><span class="pun" style="color: #666600;">;</span><span class="pln">


            </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
        </span><span class="pun" style="color: #666600;">}</span><span class="pln">
    </span><span class="pun" style="color: #666600;">});</span><span class="pln">

    buttonRight</span><span class="pun" style="color: #666600;">.</span><span class="pln">setOnTouchListener</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">new</span><span class="pln"> </span><span class="typ" style="color: #660066;">View</span><span class="pun" style="color: #666600;">.</span><span class="typ" style="color: #660066;">OnTouchListener</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
        </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
        </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> onTouch</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">View</span><span class="pln"> v</span><span class="pun" style="color: #666600;">,</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pln"> </span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">if</span><span class="pln"> </span><span class="pun" style="color: #666600;">((</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getAction</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">==</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_MOVE</span><span class="pun" style="color: #666600;">)||(</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getActionMasked</span><span class="pun" style="color: #666600;">()!=</span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_UP</span><span class="pun" style="color: #666600;">))</span><span class="pln">
            </span><span class="pun" style="color: #666600;">{</span><span class="pln">
                motorLeft </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                motorRight </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">float</span><span class="pun" style="color: #666600;">)</span><span class="lit" style="color: #006666;">0.5</span><span class="pun" style="color: #666600;">;</span><span class="pln">
            </span><span class="pun" style="color: #666600;">}</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">else</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="lit" style="color: #006666;">0</span><span class="pun" style="color: #666600;">;</span><span class="pln">


            </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
        </span><span class="pun" style="color: #666600;">}</span><span class="pln">
    </span><span class="pun" style="color: #666600;">});</span><span class="pln">

    buttonUp</span><span class="pun" style="color: #666600;">.</span><span class="pln">setOnTouchListener</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">new</span><span class="pln"> </span><span class="typ" style="color: #660066;">View</span><span class="pun" style="color: #666600;">.</span><span class="typ" style="color: #660066;">OnTouchListener</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
        </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
        </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> onTouch</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">View</span><span class="pln"> v</span><span class="pun" style="color: #666600;">,</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pln"> </span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">if</span><span class="pln"> </span><span class="pun" style="color: #666600;">((</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getAction</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">==</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_MOVE</span><span class="pun" style="color: #666600;">)||(</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getActionMasked</span><span class="pun" style="color: #666600;">()!=</span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_UP</span><span class="pun" style="color: #666600;">))</span><span class="pln">
            </span><span class="pun" style="color: #666600;">{</span><span class="pln">
                motorLeft </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                motorRight </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="lit" style="color: #006666;">1</span><span class="pun" style="color: #666600;">;</span><span class="pln">
            </span><span class="pun" style="color: #666600;">}</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">else</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="lit" style="color: #006666;">0</span><span class="pun" style="color: #666600;">;</span><span class="pln">


            </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
        </span><span class="pun" style="color: #666600;">}</span><span class="pln">
    </span><span class="pun" style="color: #666600;">});</span><span class="pln">


    buttonDown</span><span class="pun" style="color: #666600;">.</span><span class="pln">setOnTouchListener</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">new</span><span class="pln"> </span><span class="typ" style="color: #660066;">View</span><span class="pun" style="color: #666600;">.</span><span class="typ" style="color: #660066;">OnTouchListener</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
        </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
        </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> onTouch</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">View</span><span class="pln"> v</span><span class="pun" style="color: #666600;">,</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pln"> </span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">if</span><span class="pln"> </span><span class="pun" style="color: #666600;">((</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getAction</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">==</span><span class="pln"> </span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_MOVE</span><span class="pun" style="color: #666600;">)||(</span><span class="kwd" style="color: #000088;">event</span><span class="pun" style="color: #666600;">.</span><span class="pln">getActionMasked</span><span class="pun" style="color: #666600;">()!=</span><span class="typ" style="color: #660066;">MotionEvent</span><span class="pun" style="color: #666600;">.</span><span class="pln">ACTION_UP</span><span class="pun" style="color: #666600;">))</span><span class="pln">
            </span><span class="pun" style="color: #666600;">{</span><span class="pln">
                motorLeft </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                motorRight </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">float</span><span class="pun" style="color: #666600;">)</span><span class="lit" style="color: #006666;">0.5</span><span class="pun" style="color: #666600;">;</span><span class="pln">
            </span><span class="pun" style="color: #666600;">}</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">else</span><span class="pln">
                speed </span><span class="pun" style="color: #666600;">=</span><span class="pln"> </span><span class="lit" style="color: #006666;">0</span><span class="pun" style="color: #666600;">;</span><span class="pln">


            </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">false</span><span class="pun" style="color: #666600;">;</span><span class="pln">
        </span><span class="pun" style="color: #666600;">}</span><span class="pln">
    </span><span class="pun" style="color: #666600;">});</span><span class="pln">

</span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End onCreate</span><span class="pln">

</span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="kwd" style="color: #000088;">void</span><span class="pln"> enableUi</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">final</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> enable</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
    runOnUiThread</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">new</span><span class="pln"> </span><span class="typ" style="color: #660066;">Runnable</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
        </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
        </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">void</span><span class="pln"> run</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">

            toggleButtonLedSTAT</span><span class="pun" style="color: #666600;">.</span><span class="pln">setEnabled</span><span class="pun" style="color: #666600;">(</span><span class="pln">enable</span><span class="pun" style="color: #666600;">);</span><span class="pln"> </span><span class="com" style="color: #880000;">// the toggleButton is disable</span><span class="pln">
            toggleButtonLedSTAT</span><span class="pun" style="color: #666600;">.</span><span class="pln">setChecked</span><span class="pun" style="color: #666600;">(</span><span class="pln">enable</span><span class="pun" style="color: #666600;">);</span><span class="pln"> </span><span class="com" style="color: #880000;">// switch on the toggleButton</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">if</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="pln">enable</span><span class="pun" style="color: #666600;">)</span><span class="pln">
                </span><span class="typ" style="color: #660066;">Toast</span><span class="pun" style="color: #666600;">.</span><span class="pln">makeText</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">MainActivity</span><span class="pun" style="color: #666600;">.</span><span class="kwd" style="color: #000088;">this</span><span class="pun" style="color: #666600;">,</span><span class="pln"> getString</span><span class="pun" style="color: #666600;">(</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="kwd" style="color: #000088;">string</span><span class="pun" style="color: #666600;">.</span><span class="typ" style="color: #660066;">IOIOConnected</span><span class="pun" style="color: #666600;">),</span><span class="pln"> </span><span class="typ" style="color: #660066;">Toast</span><span class="pun" style="color: #666600;">.</span><span class="pln">LENGTH_LONG</span><span class="pun" style="color: #666600;">).</span><span class="pln">show</span><span class="pun" style="color: #666600;">();</span><span class="pln">
            </span><span class="kwd" style="color: #000088;">else</span><span class="pln">
                </span><span class="typ" style="color: #660066;">Toast</span><span class="pun" style="color: #666600;">.</span><span class="pln">makeText</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">MainActivity</span><span class="pun" style="color: #666600;">.</span><span class="kwd" style="color: #000088;">this</span><span class="pun" style="color: #666600;">,</span><span class="pln"> getString</span><span class="pun" style="color: #666600;">(</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="kwd" style="color: #000088;">string</span><span class="pun" style="color: #666600;">.</span><span class="typ" style="color: #660066;">IOIODisconnected</span><span class="pun" style="color: #666600;">),</span><span class="pln"> </span><span class="typ" style="color: #660066;">Toast</span><span class="pun" style="color: #666600;">.</span><span class="pln">LENGTH_LONG</span><span class="pun" style="color: #666600;">).</span><span class="pln">show</span><span class="pun" style="color: #666600;">();</span><span class="pln">

        </span><span class="pun" style="color: #666600;">}</span><span class="pln">
    </span><span class="pun" style="color: #666600;">});</span><span class="pln">
</span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End enableUi</span><span class="pln">


</span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
</span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="typ" style="color: #660066;">IOIOLooper</span><span class="pln"> createIOIOLooper</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">new</span><span class="pln"> </span><span class="typ" style="color: #660066;">Looper</span><span class="pun" style="color: #666600;">();</span><span class="pln">
</span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End IOIOLooper</span><span class="pln">


</span><span class="kwd" style="color: #000088;">class</span><span class="pln"> </span><span class="typ" style="color: #660066;">Looper</span><span class="pln"> </span><span class="kwd" style="color: #000088;">extends</span><span class="pln"> </span><span class="typ" style="color: #660066;">BaseIOIOLooper</span><span class="pun" style="color: #666600;">{</span><span class="pln">

    </span><span class="com" style="color: #880000;">// Declare PIN</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">DigitalOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinDO0</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// LED STAT</span><span class="pln">

    </span><span class="com" style="color: #880000;">// Motor DC : Right</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">DigitalOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinDIO36</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// L293D In 3</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">DigitalOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinDIO37</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// L293D In 4</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">PwmOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinPWM38</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// L293D Enable 2</span><span class="pln">

    </span><span class="com" style="color: #880000;">// Motor DC : Left</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">DigitalOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinDIO40</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// L293D In 2</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">DigitalOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinDIO41</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// L293D In 1</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">private</span><span class="pln"> </span><span class="typ" style="color: #660066;">PwmOutput</span><span class="pln"> </span><span class="typ" style="color: #660066;">PinPWM39</span><span class="pun" style="color: #666600;">;</span><span class="pln"> </span><span class="com" style="color: #880000;">// L293D Enable 1</span><span class="pln">



    </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">protected</span><span class="pln"> </span><span class="kwd" style="color: #000088;">void</span><span class="pln"> setup</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="kwd" style="color: #000088;">throws</span><span class="pln"> </span><span class="typ" style="color: #660066;">ConnectionLostException</span><span class="pun" style="color: #666600;">,</span><span class="pln"> </span><span class="typ" style="color: #660066;">InterruptedException</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
// super.setup();
// Assign PIN
// LED STAT
PinDO0 = ioio_.openDigitalOutput(0, true);
        </span><span class="com" style="color: #880000;">// Motor DC : Right</span><span class="pln">
        </span><span class="typ" style="color: #660066;">PinDIO36</span><span class="pln"> </span><span class="pun" style="color: #666600;">=</span><span class="pln"> ioio_</span><span class="pun" style="color: #666600;">.</span><span class="pln">openDigitalOutput</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">36</span><span class="pun" style="color: #666600;">);</span><span class="pln">
        </span><span class="typ" style="color: #660066;">PinDIO37</span><span class="pln"> </span><span class="pun" style="color: #666600;">=</span><span class="pln"> ioio_</span><span class="pun" style="color: #666600;">.</span><span class="pln">openDigitalOutput</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">37</span><span class="pun" style="color: #666600;">);</span><span class="pln">
        </span><span class="typ" style="color: #660066;">PinPWM38</span><span class="pln"> </span><span class="pun" style="color: #666600;">=</span><span class="pln"> ioio_</span><span class="pun" style="color: #666600;">.</span><span class="pln">openPwmOutput</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">38</span><span class="pun" style="color: #666600;">,</span><span class="lit" style="color: #006666;">100</span><span class="pun" style="color: #666600;">);</span><span class="pln">


        </span><span class="com" style="color: #880000;">// Motor DC : Left</span><span class="pln">
        </span><span class="typ" style="color: #660066;">PinDIO40</span><span class="pln"> </span><span class="pun" style="color: #666600;">=</span><span class="pln"> ioio_</span><span class="pun" style="color: #666600;">.</span><span class="pln">openDigitalOutput</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">40</span><span class="pun" style="color: #666600;">);</span><span class="pln">
        </span><span class="typ" style="color: #660066;">PinDIO41</span><span class="pln"> </span><span class="pun" style="color: #666600;">=</span><span class="pln"> ioio_</span><span class="pun" style="color: #666600;">.</span><span class="pln">openDigitalOutput</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">41</span><span class="pun" style="color: #666600;">);</span><span class="pln">
        </span><span class="typ" style="color: #660066;">PinPWM39</span><span class="pln"> </span><span class="pun" style="color: #666600;">=</span><span class="pln"> ioio_</span><span class="pun" style="color: #666600;">.</span><span class="pln">openPwmOutput</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">39</span><span class="pun" style="color: #666600;">,</span><span class="lit" style="color: #006666;">100</span><span class="pun" style="color: #666600;">);</span><span class="pln">


        enableUi</span><span class="pun" style="color: #666600;">(</span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">);</span><span class="pln"> </span><span class="com" style="color: #880000;">// Start IOIO</span><span class="pln">
    </span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End setup</span><span class="pln">

    </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">void</span><span class="pln"> loop</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="kwd" style="color: #000088;">throws</span><span class="pln"> </span><span class="typ" style="color: #660066;">ConnectionLostException</span><span class="pun" style="color: #666600;">,</span><span class="pln"> </span><span class="typ" style="color: #660066;">InterruptedException</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
// super.loop();
        </span><span class="typ" style="color: #660066;">PinDO0</span><span class="pun" style="color: #666600;">.</span><span class="pln">write</span><span class="pun" style="color: #666600;">(!</span><span class="pln">toggleButtonLedSTAT</span><span class="pun" style="color: #666600;">.</span><span class="pln">isChecked</span><span class="pun" style="color: #666600;">());</span><span class="pln">


            </span><span class="typ" style="color: #660066;">PinPWM39</span><span class="pun" style="color: #666600;">.</span><span class="pln">setDutyCycle</span><span class="pun" style="color: #666600;">(</span><span class="pln">speed</span><span class="pun" style="color: #666600;">);</span><span class="pln">
            </span><span class="typ" style="color: #660066;">PinDIO41</span><span class="pun" style="color: #666600;">.</span><span class="pln">write</span><span class="pun" style="color: #666600;">(</span><span class="pln">motorLeft</span><span class="pun" style="color: #666600;">);</span><span class="pln">
            </span><span class="typ" style="color: #660066;">PinDIO40</span><span class="pun" style="color: #666600;">.</span><span class="pln">write</span><span class="pun" style="color: #666600;">(!</span><span class="pln">motorLeft</span><span class="pun" style="color: #666600;">);</span><span class="pln">

            </span><span class="typ" style="color: #660066;">PinPWM38</span><span class="pun" style="color: #666600;">.</span><span class="pln">setDutyCycle</span><span class="pun" style="color: #666600;">(</span><span class="pln">speed</span><span class="pun" style="color: #666600;">);</span><span class="pln">
            </span><span class="typ" style="color: #660066;">PinDIO37</span><span class="pun" style="color: #666600;">.</span><span class="pln">write</span><span class="pun" style="color: #666600;">(</span><span class="pln">motorRight</span><span class="pun" style="color: #666600;">);</span><span class="pln">
            </span><span class="typ" style="color: #660066;">PinDIO36</span><span class="pun" style="color: #666600;">.</span><span class="pln">write</span><span class="pun" style="color: #666600;">(!</span><span class="pln">motorRight</span><span class="pun" style="color: #666600;">);</span><span class="pln">



        </span><span class="kwd" style="color: #000088;">try</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
            </span><span class="typ" style="color: #660066;">Thread</span><span class="pun" style="color: #666600;">.</span><span class="pln">sleep</span><span class="pun" style="color: #666600;">(</span><span class="lit" style="color: #006666;">10</span><span class="pun" style="color: #666600;">);</span><span class="pln">
        </span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="kwd" style="color: #000088;">catch</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">InterruptedException</span><span class="pln"> e</span><span class="pun" style="color: #666600;">)</span><span class="pln">
        </span><span class="pun" style="color: #666600;">{</span><span class="pln">
            e</span><span class="pun" style="color: #666600;">.</span><span class="pln">printStackTrace</span><span class="pun" style="color: #666600;">();</span><span class="pln">
        </span><span class="pun" style="color: #666600;">}</span><span class="pln">

    </span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End Loop</span><span class="pln">



    </span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">void</span><span class="pln"> disconnected</span><span class="pun" style="color: #666600;">()</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
// super.disconnected();
enableUi
(false);
toggleButtonLedSTAT
.setEnabled(false); // the toggleButton is disable
toggleButtonLedSTAT
.setChecked(false); // switch off the toggleButton
Toast.makeText(MainActivity.this,getString(R.string.IOIODisconnected),Toast.LENGTH_LONG).show();
    </span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End disconnected</span><span class="pln">
</span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">//End Looper</span><span class="pln">


</span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
</span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> onCreateOptionsMenu</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">Menu</span><span class="pln"> menu</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
    getMenuInflater</span><span class="pun" style="color: #666600;">().</span><span class="pln">inflate</span><span class="pun" style="color: #666600;">(</span><span class="pln">R</span><span class="pun" style="color: #666600;">.</span><span class="pln">menu</span><span class="pun" style="color: #666600;">.</span><span class="pln">menu_main</span><span class="pun" style="color: #666600;">,</span><span class="pln"> menu</span><span class="pun" style="color: #666600;">);</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">;</span><span class="pln">
</span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End onCreateOptionsMenu</span><span class="pln">

</span><span class="lit" style="color: #006666;">@Override</span><span class="pln">
</span><span class="kwd" style="color: #000088;">public</span><span class="pln"> </span><span class="kwd" style="color: #000088;">boolean</span><span class="pln"> onOptionsItemSelected</span><span class="pun" style="color: #666600;">(</span><span class="typ" style="color: #660066;">MenuItem</span><span class="pln"> item</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">int</span><span class="pln"> id </span><span class="pun" style="color: #666600;">=</span><span class="pln"> item</span><span class="pun" style="color: #666600;">.</span><span class="pln">getItemId</span><span class="pun" style="color: #666600;">();</span><span class="pln">

    </span><span class="com" style="color: #880000;">//noinspection SimplifiableIfStatement</span><span class="pln">
    </span><span class="kwd" style="color: #000088;">if</span><span class="pln"> </span><span class="pun" style="color: #666600;">(</span><span class="pln">id </span><span class="pun" style="color: #666600;">==</span><span class="pln"> R</span><span class="pun" style="color: #666600;">.</span><span class="pln">id</span><span class="pun" style="color: #666600;">.</span><span class="pln">action_settings</span><span class="pun" style="color: #666600;">)</span><span class="pln"> </span><span class="pun" style="color: #666600;">{</span><span class="pln">
        </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">true</span><span class="pun" style="color: #666600;">;</span><span class="pln">
    </span><span class="pun" style="color: #666600;">}</span><span class="pln">

    </span><span class="kwd" style="color: #000088;">return</span><span class="pln"> </span><span class="kwd" style="color: #000088;">super</span><span class="pun" style="color: #666600;">.</span><span class="pln">onOptionsItemSelected</span><span class="pun" style="color: #666600;">(</span><span class="pln">item</span><span class="pun" style="color: #666600;">);</span><span class="pln">
</span><span class="pun" style="color: #666600;">}</span><span class="pln"> </span><span class="com" style="color: #880000;">// End onOptionsItemSelected</span><span class="pln">
}

 

 

 

 

 

 


This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/ailgorrc-my-first-rc-car-with-ioio-l293d

Questions about the IOIO and your bot.

Hello,

Nice bot :slight_smile:

Q: What is the board to the right of the IOIO?  A Bluetooth board?

Q: So the only code needed is on the Android side?  The IOIO needs no code downloaded?

Thanks!

HiRight of IOIO, it’s a

Hi

Right of IOIO, it’s a Charger Module LiPo Pro POW12059P (see here : https://www.robotshop.com/letsmakerobots/ioio-robot-solar-cell-and-self-powering-0 )

 I plug Accu+Solar Cells and the IOIO itself.

Yes it’s Java code build in Android Studio 1.01 + IOIO Lib obviously.

You don’t upload code in IOIO, Android send command to IOIO or receive data (sensor etc…) from IOIO by USB or Bluetooth. But for me the next step is to command the robot by Wifi from an Android as Remote Command to the Android Plug to the IOIO.

The Android Plug to the IOIO has Camera, GPS, several sensor… 

Quite like this : :https://www.youtube…h?v=n6ypGlTCbKk 


 


 


**Thanks for the info **

The in-code streamed video looks like a nice option. I may take a closer look at the IOIO later.

Neat bot. And don’t worry:
Neat bot. And don’t worry: novice is gotten rid of by experience. No single part of robotics is that very difficult. All together, though, they look like magic. Don’t be fooled, though, they can each be learned.

Vertical solar panel

Hi,

Sorry I didn’t see your answer at :

https://www.robotshop.com/letsmakerobots/ioio-robot-solar-cell-and-self-powering-0

So, you are powering your IOIO board together with the 2x motors from the POW12059P ?

 

From my knowledge, the vertical position for the solar panel is the worst for efficiency.

 

In your electrical diagram, you drawn the solar panel in paralell to the battery regulator, if I’m not wrong.

I think that if the sign for the battery represents yours solar panel, it should be connected to the regulator only. Because, potentially the voltage of the solar panel can exceed the one allowed by your components in the circuit.

 

Nice build, in any case !

Thank you for showing up the IOIO.

 

Solar panel is not drawning

Solar panel is not drawning in the schema (only battery and the module charger)… but it works fine.

Its position vertical is because of my window the robot will get more sun like this than horizontal. The Robot will never go outside. It will probably stay all the day at home to get sun. Lucky Robot :slight_smile: