Things used in this project

Schematics

Robot Chassis
Author
https://grabcad.com/library/chassis-of-a-2wd-autonomous-robot-1
Chassis.SLDPRT

Code

Robot control codeArduino
Differential drive robot code
/*

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

/* Include 1Sheeld library. */
#include <OneSheeld.h>
#include <AFMotor.h>

// Motor objects, motor number on the motor shield board
AF_DCMotor motorLeft(1);
AF_DCMotor motorRight(2);

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);
	}
	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);
	}
}
Modified code for v2.3 library by Garry GerwerArduino
Created by Garry Grewer, this code works for the newer version of the motor shield v2.3
/*Gamepad Shield Example
This example shows an application on 1Sheeld's gamepad shield.

******* This is modified to use the adafruit motorshield V2.3 *********

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 /
/ Include 1Sheeld library. */
#define INCLUDE_GAMEPAD_SHIELD
#include <OneSheeld.h>
//#include <AFMotor.h>
#include <Adafruit_MotorShield.h> //for v2.3 motorshield

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

// Motor objects, motor number on the motor shield board
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

void setup()
{
/* Start communication. */
OneSheeld.begin();
AFMS.begin();

// The LED just works as an indicator that the 1Sheeld is working fine
pinMode(ledPin, OUTPUT);
myMotor->setSpeed(150);
myOtherMotor->setSpeed(150);

}
void loop()
{
/* Always check the status of gamepad buttons. */
if (GamePad.isDownPressed())
{
myMotor->run(BACKWARD);
myOtherMotor->run(BACKWARD);

digitalWrite(ledPin, HIGH);
}
else if (GamePad.isUpPressed())
{
myMotor->run(FORWARD);
myOtherMotor->run(FORWARD);
digitalWrite(ledPin, HIGH);
}
else if (GamePad.isLeftPressed())
{
myMotor->run(BACKWARD);
myOtherMotor->run(FORWARD);
digitalWrite(ledPin, HIGH);
}
else if (GamePad.isRightPressed())
{
myMotor->run(FORWARD);
myOtherMotor->run(BACKWARD);
digitalWrite(ledPin, HIGH);
}
else
{
myMotor->run(RELEASE);
myOtherMotor->run(RELEASE);
digitalWrite(ledPin, LOW);
}
}

Credits

Msp
Ahmed Hamdy

Computer and Communications engineering student, Programming addict, Arduino lover, Teaching the future generations

Contact
E7483e9a8f0f6e8bdefd7ee6845d9430
Garry Gerwer

Hobbyist

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Laser Stuff
Easy
  • 537
  • 3

A laser module that makes light patterns.

I Keep my Cucumber Growing Conditions Moist - Part 2
Easy
  • 238
  • 4

Full instructions

This is the next step with an Ultrasonic HC-SR04 Echo and LCD 1602.

LEDog Collar
Easy
  • 981
  • 10

Full instructions

The LEDog collar lights up when it gets dark, helping you locate your dog from far away.

Handheld Infinity Kaleidoscope Group Kit
Easy
  • 2,714
  • 30

Full instructions

Use the orientation sensor in your Arduino 101 to control a cool Petri dish infinity-mirror illusion. This project is great for groups.

Arduino 101 BLE RGB Lamp
Easy
  • 550
  • 7

Full instructions

Create your own RGB controlled lamp with Arduino 101 using BLE.

SECURITY SYSTEM AND ACCESs CONTROL WITH ARDUINO AND RFID
Easy
  • 682
  • 8

Full instructions

To enter passwords and to allow access to a door or to drive an electronic device, now we will use a RFID device

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback