Introduction: Adafruit Motor Shield & Funduino

Picture of Adafruit Motor Shield & Funduino

Download our FREE Arduino Project Code

Attach Funduino and Motor Shield together.

Step 1: IDE

Picture of 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

Picture of Bluetooth Module

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

Step 4: Upload Sketch for Bluetooth

Picture of Upload Sketch for Bluetooth

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


#include

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

Picture of 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 build

Comments

BeckyF2 (author)2014-11-06
BeckyF2 (author)2014-11-06

Dear
Sir,

Now
is the best time to buy Cheap good-quality Arduino/Funduino products you like,
we’re celebrating our 8 years’ anniversary and have a competition with other companies,
pricewill
be negotiable to reward all our customers, so come on, this is your time now!

vsharma23 (author)2014-10-11

can i use any other andriod app to control it 8f yes can you name them.

About This Instructable

21,987views

28favorites

License:

More by ALP Electronic Innovation:Smart Window Using Smartphone & ArduinoArduino, LCD 16x2 & ButtonArduino & Servo Motor to Your Music Box
Add instructable to: