Dear Ytai,

Heres a link where I have purchased this 4WD Motor. I have followed these 
images
http://www.tohobby.com/it/4-dc-motor-driver-module-arduino-dc-motor-shield-l298n-motor-control-board.html

I also attach my code for motor bellow:

class Looper extends BaseIOIOLooper {

 //Pins for Controlls

 private DigitalOutput D1A, D1B, D2A, D2B, D3A, D3B, D4A, D4B;

 private PwmOutput PWM1, PWM2, PWM3, PWM4;

  public void setup() throws ConnectionLostException {

 read = ioio_.openPulseInput(34, PulseInput.PulseMode.POSITIVE);

        D1A = ioio_.openDigitalOutput(16, false);

        D1B = ioio_.openDigitalOutput(17, false);

        D2A = ioio_.openDigitalOutput(18, false);

        D2B = ioio_.openDigitalOutput(19, false);

        D3A = ioio_.openDigitalOutput(20, false);

        D3B = ioio_.openDigitalOutput(21, false);

        D4A = ioio_.openDigitalOutput(22, false);

        D4B = ioio_.openDigitalOutput(23, false);

        PWM1 = ioio_.openPwmOutput(27, 100);

        PWM1.setDutyCycle(0);

        PWM2 = ioio_.openPwmOutput(28, 100);

        PWM2.setDutyCycle(0);

        PWM3 = ioio_.openPwmOutput(29, 100);

        PWM3.setDutyCycle(0);

        PWM4 = ioio_.openPwmOutput(30, 100);

        PWM4.setDutyCycle(0);

         

        runOnUiThread(new Runnable() { 

            public void run() { 

             

            Toast.makeText(getApplicationContext(), 

   "Go IOIO!", Toast.LENGTH_SHORT).show();

            }        

        }); 

 }

  //Main Controls

 public void loop() throws ConnectionLostException, InterruptedException { 

 if(dutyLeft > 0) {

  PWM1.setDutyCycle(dutyLeft);

  PWM2.setDutyCycle(dutyLeft);

     D1A.write(false);

     D2A.write(false);

     D1B.write(true);

     D2B.write(true);

 } else if(dutyLeft < 0) {

  PWM1.setDutyCycle(Math.abs(dutyLeft));

  PWM2.setDutyCycle(Math.abs(dutyLeft));

     D1A.write(true);

     D2A.write(true);

     D1B.write(false);

     D2B.write(false);

 } else {

  PWM1.setDutyCycle(0);

  PWM2.setDutyCycle(0);

     D1A.write(false);

     D2A.write(false);

     D1B.write(false);

     D2B.write(false);

 }

   if(dutyRight > 0) {

  PWM3.setDutyCycle(dutyRight);

  PWM4.setDutyCycle(dutyRight);

     D3A.write(true);

     D4A.write(true);

     D3B.write(false);

     D4B.write(false);

 } else if(dutyRight < 0) {

  PWM3.setDutyCycle(Math.abs(dutyRight));

  PWM4.setDutyCycle(Math.abs(dutyRight));

     D3A.write(false);

     D4A.write(false);

     D3B.write(true);

     D4B.write(true);

 } else {

  PWM3.setDutyCycle(0);

  PWM4.setDutyCycle(0);

     D3A.write(false);

     D4A.write(false);

     D3B.write(false);

     D4B.write(false);

 }       

     try { 

     Thread.sleep(100); 

     } catch (InterruptedException e) { 

         e.printStackTrace(); 

     } 

    } 

}

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to