Hello, I've ordered a motor shield and I want to make this project at http://arduino.cc/forum/index.php/topic,90809.0.html but my motor shield used is the ladyada motor shield and the code is written for another motor shield. I've tried to fix this so it would work with my motor shield which is coming some time soon, it seems to compile without any errors but I just want someone that knows way more than me at this to help and see if this would work.
#include <AFMotor.h>
AF_DCMotor frontleft(1, MOTOR12_64KHZ);
AF_DCMotor frontright(2, MOTOR12_64KHZ);
AF_DCMotor backleft(3, MOTOR34_1KHZ);
AF_DCMotor backright(4, MOTOR34_1KHZ);
//Acceleration sensor from the smartphone is used to drive the robot forward backwords left and right
//inspired from http://www.arduino.cc/playground/Code/HTCDesire
//arduino + amarino + HTC Wildfire
#include <MeetAndroid.h>
#define IDLE 0
#define RINGING 1
#define OFFHOOK 2
MeetAndroid meetAndroid;
void setup()
{
Serial.begin(115200);
meetAndroid.registerFunction(phoneorient, 'A');
int input=0;
frontleft.setSpeed(255);
frontright.setSpeed(255);
backleft.setSpeed(255);
backright.setSpeed(255);
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
void phoneorient(byte flag, byte numOfValues)
{
//Phone Orientation Controller
int values[]={0,0,0};
meetAndroid.getIntValues(values);
int Steer=values[1]; //
int Delta=values[2]; //
int Heading=values[3]; //
if (Steer >=5)
{ //left
frontright.run(BACKWARD);
frontleft.run(FORWARD);
backleft.run(FORWARD);
backright.run(BACKWARD);
}
else if (Steer <=-5)
{ //right
frontright.run(FORWARD);
frontleft.run(BACKWARD);
backleft.run(BACKWARD);
backright.run(FORWARD);
}
else if (Delta >=5) { //forward
frontright.run(FORWARD);
frontleft.run(FORWARD);
backleft.run(FORWARD);
backright.run(FORWARD);
}
else if (Delta <=-5) { //back
frontright.run(BACKWARD);
frontleft.run(BACKWARD);
backleft.run(BACKWARD);
backright.run(BACKWARD);
}
else
{
frontright.run(RELEASE);
frontleft.run(RELEASE);
backleft.run(RELEASE);
backright.run(RELEASE);
}
Serial.println(values[1]); //Throttle , Pitch
Serial.println(values[2]); //Steering, Roll
Serial.println(values[3]); // Heading, degree
}
It's a 4WD ground robot, I'm using a Galaxy Nexus and going to use a JY-MCU bluetooth module. Please reply to this thread, it would really help.