Hi, I'm attempting to build a robot car that will be controlled using 1sheeld and connecting it with the gamepad on the 1sheeld app. The motor shield I'm using is adafruit motor shield v2.3 and my car uses three motors. The car uses 4 motors and the coding was able to upload onto the car and sync with the bluetooth however none of the buttons on the gamepad move any of the wheels. In the coding I only have it to operate two motors just to test it out. I also added an extra battery source but that doesn't seem to be the case. I believe the coding is missing connection with the buttons on the gamepad but I'm not sure how to include that. On the app, it allows me to assign pin numbers to each up, down, right, left, button but I'm not sure how to integrate that with the coding. I'm new to Arduino and would greatly appreciate any help!!! My project is due by next week and I can get the car to operate however just not bluetooth controlled. This is the coding that I'm using below:
/*
Gamepad Shield Example
This example shows an application on 1Sheeld's gamepad shield.
OPTIONAL:
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.
*/
int ledPin = 13;
#define CUSTOM_SETTINGS
/* Use the game pad */
#define INCLUDE_GAMEPAD_SHIELD
#define FORWARD 1
#define BACKWARD 2
#define BRAKE 3
#define RELEASE 4
/* Include 1Sheeld library. */
#include <time.h>
#include <OneSheeld.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <Servo.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Motor objects, motor number on the motor shield board
Adafruit_DCMotor * motorLeft = AFMS.getMotor(1); // M1 Left Front
Adafruit_DCMotor * motorRight= AFMS.getMotor(2); // M2 Right Front
void setup()
{
/* Start communication. */
OneSheeld.begin();
// The LED just works as an indicator that the 1Sheeld is working fine
pinMode(ledPin, OUTPUT);
motorLeft->setSpeed(100);
motorRight->setSpeed(100);
}
void loop()
{
/* Always check the status of gamepad buttons. */
if (GamePad.isDownPressed())
{
motorLeft->run(BACKWARD);
motorRight->run(BACKWARD);
digitalWrite(ledPin, HIGH);
printf("GamePad.isDownPressed");
}
else if (GamePad.isUpPressed())
{
motorLeft->run(FORWARD);
motorRight->run(FORWARD);
digitalWrite(ledPin, HIGH);
}
else if (GamePad.isLeftPressed())
{
motorLeft->run(BACKWARD);
motorRight->run(FORWARD);
digitalWrite(ledPin, HIGH);
}
else if (GamePad.isRightPressed())
{
motorLeft->run(FORWARD);
motorRight->run(BACKWARD);
digitalWrite(ledPin, HIGH);
}
else
{
motorLeft->run(RELEASE);
motorRight->run(RELEASE);
digitalWrite(ledPin, LOW);
}
}