loading

This tutorial is brought to you by ALP ELectronic Innovation.

Download our FREE Arduino Project Code here.

Attach Funduino and Motor Shield together.

Step 1: IDE

Open the Arduino IDE then click Tools / Board / Arduino Duemilanove w/ AT328

Step 2: Upload the Sketch

/*
Upload the code below, make sure that you plug the USB cable and choose the right Serial Port.
Test the (2) DC motors to move Forward and Backward.
*/

#include

int i;

// DC motor on M1
AF_DCMotor motor(1);

// DC motor on M2
AF_DCMotor motor2(2);

void setup() {
  
  // Turn ON DC MOTOR #1
  motor.setSpeed(200);
  motor.run(RELEASE);
 
  // TURN ON DC MOTOR #2
  motor2.setSpeed(200);
  motor2.run(RELEASE);
}


void loop() {
  motor.run(FORWARD);
  motor2.run(FORWARD);
 
  for (i=0; i<255; i++) {
    motor.setSpeed(i);
    motor2.setSpeed(i);  
    delay(10);
}

  motor.run(BACKWARD);
  motor2.run(BACKWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i); 
    motor2.setSpeed(i);
    delay(10);

  }
}

// code ends here

Step 3: Bluetooth Module

You can also attach a Bluetooth module to control the motor using your Android phone.

Step 4: Upload Sketch for Bluetooth

/* Use your Android phone to control your motor FORWARD / REVERSE / LEFT / RIGHT
    Upload code below.
*/


#include <AFMotor.h>

char val;  // Variable to receive data from the serial port

// DC motor on M1
AF_DCMotor motor(1);

// DC motor on M2
AF_DCMotor motor2(2);

int i;

void setup() {
  Serial.begin(115200);         
  
  // turn on motor #1
  motor.setSpeed(200);
  motor.run(RELEASE);
 
  // turn on motor #2
  motor2.setSpeed(200);
  motor2.run(RELEASE);
}

// Move FORWARD
void go_forward(){
  
  motor.run(FORWARD);
  motor2.run(FORWARD);
 
  for (i=0; i<255; i++) {
    motor.setSpeed(i);
    motor2.setSpeed(i);  
  }
}
// Move REVERSE
void go_reverse(){
  
  motor.run(BACKWARD);
  motor2.run(BACKWARD);
 
  for (i=0; i<255; i++) {
    motor.setSpeed(i); 
    motor2.setSpeed(i);
   }
  }
// Move LEFT
void go_left(){
  
  motor.run(FORWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i); 
   }
  }
  // Move RIGHT
void go_right(){
  
  motor2.run(FORWARD);
  for (i=0; i<255; i++) {
    motor2.setSpeed(i);
   }
  } 
 
// Read serial port and perform command
void performCommand() {
  if (Serial.available()) {
    val = Serial.read();
  }
     if (val == 'f') { // Forward
      go_forward();
//    } else if (val == 'z') { // Stop Forward
//      stop_go_forward();
    } else if (val == 'b') { // Reverse
      go_reverse();
    } else if (val == 'y') { // Stop Reverse
//      stop_go_reverse();
    } else if (val == 'l') { // Right
      go_right();
    } else if (val == 'r') { // Left
      go_left();
//    } else if (val == 't') { // Stop Car using Turbo function
//      stop_car();
    }

}
void loop() {
  performCommand();

}

// code ends here

Step 5: Android App

Use the "Smart Home with Voice command" app to test your Bluetooth module.

Google PlayStore.

Step 6: WarBot

You may also want to buildWarBot.

<p>our website:<a href="http://www.okystar.en.alibaba.com/" rel="nofollow">http://www.okystar.en.alibaba.com/</a></p>
<p>Dear <br>Sir,</p><p>Now <br>is the best time to buy Cheap good-quality Arduino/Funduino products you like, <br>we&rsquo;re celebrating our 8 years&rsquo; anniversary and have a competition with other companies, <br>pricewill <br>be negotiable to reward all our customers, so come on, this is your time <strong>now</strong>!</p>
<p>can i use any other andriod app to control it 8f yes can you name them.</p>

About This Instructable

21,591views

27favorites

License:

More by ALP Electronic Innovation:Smart Window using Smartphone & Arduino Arduino, LCD 16x2 & Button Arduino & Servo Motor to your Music box 
Add instructable to: