Question
I have some errors in the code below. Can you help me fix them, please? #include #include #include #include Adafruit_MotorShield AFMS = Adafruit_MotorShield () ;
I have some errors in the code below. Can you help me fix them, please?
#include
Adafruit_MotorShield AFMS = Adafruit_MotorShield () ;
int bluetoothTx = 18; //transmit TX1 pin bluetooth mate, arduino D2 int bluetoothTx = 19; //receive RX1 pin bluetooth mate, arduino D3 int index = 0; //defines variable index char message[256]; //defines character message, array of 56 characters
//creates pointers to motor objects Motor *1fMotor; Motor *rfMotor; Motor *lrMotor; Motor *rrMotor; //Adafruit_BLE *ble
void setup () { // put your setup code here, to run once:
Serial.begin(9600); //begin the serial monitor at 9600 bps Serial1.begin (115200); //the bluetooth rate default to 115200 bps
// initialize motor shield with the default frequency of 1.6kHz AFMS.begin ();
//motors mapping and configuration on the robot //motor1 - left front, motor2 - right rear, motor3 - rightfront, motor4 - left rear? lrMotor = new Motor (&AFMS, 1, 0); lrMotor = new Motor (&AFMS, 2, 0); lrMotor = new Motor (&AFMS, 3, 0); lrMotor = new Motor (&AFMS, 4, 0); }
void loop() {
char message [256]; if{serial1.available ()) //if bluetooth sent any characters { message [index] = (char) serial1.read(); //add the character to the message buffer
if (message[index]== 0x3f) { //check for ? character message [index+1] = \0; //add the null character to message
//TANK DRIVE using Bluetooth and cell phone app
if {!strcmp (mesage, bl?)) { lfMotor->setDrive(198, FORWARD); lrMotor->setDrive(198, FORWARD); rrMotor->setDrive(198, FORWARD); rfMotor->setDrive(198, FORWARD); } else if (!strcmp(message, b2?)) { lfMotor->setDrive(155, BACKWARD); lrMotor->setDrive(155, BACKWARD); rrMotor->setDrive(155, BACKWARD); rfMotor->setDrive(155, BACKWARD); } else if (!strcmp(message, b3?)) { lfMotor->setDrive(198, FORWARD); lrMotor->setDrive(198, FORWARD); rrMotor->setDrive(198, BACKWARD); rfMotor->setDrive(198, BACKWARD); } else if (!strcmp(message, b4?)) { lfMotor->setDrive(198, BACKWARD); lrMotor->setDrive(198, BACKWARD); rrMotor->setDrive(198, FORWARD); rfMotor->setDrive(198, FORWARD); } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started