Hi guys, I am a student working on a project that involves 2 tamiya plasma - dc motors.
I have bought the monster moto shield with UNO to run this simple 2 motor robot controlled by bluetooth using android phone. Below is my code, but I have problem compiling.
#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 100
/* VNH2SP30 pin definitions
xxx[0] controls '1' outputs
xxx[1] controls '2' outputs */
char dataIn='S';char determinant;char det;int vel = 0; //Bluetooth Stuff
/int power = 4;/
int inApin[2] = {7, 4}; // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)
int statpin = 13;
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
//initialise digital pins as o/p
for (int i=0; i<2; i++)
{
pinMode(inApin*, OUTPUT);*
_ pinMode(inBpin*, OUTPUT);_
_ pinMode(pwmpin, OUTPUT);
}
// Initialize braked*
* for (int i=0; i<2; i++)
{
digitalWrite(inApin, LOW);
digitalWrite(inBpin, LOW);
}
// motorGo(0, CW, 1023);
// motorGo(1, CCW, 1023);
}
void motorOff(int motor)
{
// Initialize braked*
* for (int i=0; i<2; i++)
{
digitalWrite(inApin, LOW);
digitalWrite(inBpin, LOW);
}
analogWrite(pwmpin[motor], 0);
}
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
if (motor <= 1)
{
if (direct <=4)
{
// Set inA[motor]
if (direct <=1)
digitalWrite(inApin[1], HIGH);
else*
* digitalWrite(inApin[1], LOW);
// Set inB[motor]
if ((direct==0)||(direct==2))
digitalWrite(inBpin[0], HIGH);
else*
* digitalWrite(inBpin[0], LOW);
analogWrite(pwmpin[0], pwm);
}
}
}
void loop()
{ det = check();*_
* while (det == 'F') // F, move forward*
* {motorGo(0,1,vel);motorGo(1,1,vel);det = check();}*
* while (det == 'B') // B, move back*
* {motorGo(0,2,vel);motorGo(1,2,vel);det = check();}*
* while (det == 'L') // L, move wheels left*
* {motorGo(0,1,vel/4);motorGo(1,1,vel);det = check();}*
* while (det == 'R') // R, move wheels right*
* {motorGo(1,1,vel/4);motorGo(0,1,vel);det = check();}*
* while (det == 'I') // I, turn right forward*
* {motorGo(0,1,vel/2);motorGo(1,1,vel);det = check();}*
* while (det == 'J') // J, turn right back*
* {motorGo(0,2,vel/2);motorGo(1,2,vel);det = check();} *
* while (det == 'G') // G, turn left forward*
* {motorGo(1,1,vel/2);motorGo(0,1,vel);det = check();}*
* while (det == 'H') // H, turn left back*
* {motorGo(1,2,vel/2);motorGo(0,2,vel);det = check();} *
* while (det == 'S') // S, stop*
* {motorGo(0,3,0);motorGo(1,3,0);det = check();}*
* //---------------------Toggle switch code------------------//*
_ /* while (det == 'U')
* {digitalWrite(power, HIGH);det = check();}
while (det == 'u')
{digitalWrite(power, LOW);det = check();}/
* //---------------------Mains Power------------------//
while (det == 'W')
{digitalWrite(statpin, HIGH);det = check();}
while (det == 'w')
{digitalWrite(statpin, LOW);det = check();}
}
int check()
{if (Serial.available() > 0) {dataIn = Serial.read();
if (dataIn == 'F'){determinant = 'F';}
else if (dataIn == 'B'){determinant = 'B';}else if (dataIn == 'L'){determinant = 'L';}
else if (dataIn == 'R'){determinant = 'R';}else if (dataIn == 'I'){determinant = 'I';}
else if (dataIn == 'J'){determinant = 'J';}else if (dataIn == 'G'){determinant = 'G';}
else if (dataIn == 'H'){determinant = 'H';}else if (dataIn == 'S'){determinant = 'S';}
else if (dataIn == '0'){vel = 400;}else if (dataIn == '1'){vel = 380;}
else if (dataIn == '2'){vel = 340;}else if (dataIn == '3'){vel = 320;}
else if (dataIn == '4'){vel = 280;}else if (dataIn == '5'){vel = 240;}
else if (dataIn == '6'){vel = 200;}else if (dataIn == '7'){vel = 160;}
else if (dataIn == '8'){vel = 120;}else if (dataIn == '9'){vel = 80;}
else if (dataIn == 'q'){vel = 40;}else if (dataIn == 'U'){determinant = 'U';}
else if (dataIn == 'u'){determinant = 'u';}else if (dataIn == 'W'){determinant = 'W';}
else if (dataIn == 'w'){determinant = 'w';}}return determinant;}
}*_
I am new to Arduino programming, please pardon me for any dumb mistakes. Hope someone can assist in identifying the problem