Project in progress
R/C Traxxas Slash with Arduino and 1Sheeld

R/C Traxxas Slash with Arduino and 1Sheeld

Control a R/C truck using your smartphone.

  • 7,720 views
  • 12 comments
  • 36 respects

Components and supplies

Screen shot 2019 03 20 at 2 38 27 pm fqndazqcx1
1Sheeld
×1
Traxxas Slash
Steering Servo, Electronic Speed Control (ESC), Motor and Battery
×1
A000066 iso both
Arduino UNO & Genuino UNO
DIYmall ( http://amzn.com/B010DHHD5O )
×1
JBtek Breadboard Power Supply
×1

About this project

Disclosure of Material Connection: I received the JBtek, 1Sheeld and DIYmall products for free so that I could provide product feedback to the company and post a product review. I am disclosing this in accordance with the Federal Trade Commission's requirements.

I have been playing with my Arduino boards lately, and I wanted to try out the servo control.  I didn't have any spare servos laying around, but I did have a Traxxas Slash R/C truck with a servo mounted in it.  I decided to play around with the steering servo, and then I got ideas of how to control it using some of the 1Sheeld capabilities.

I decided that I wanted to use my smartphone to control the truck just by tilting the phone (left/right for steering, forward/back for power).  After some time playing around with the code and hardware, I had a rough working setup.

Components I used:
- Small USB battery pack (to power the Arduino + 1Sheeld)
- JBtek breadboard power supply
- DIYmall Arduino compatible UNO R3
- Solderless breadboard + jumper wires
- Traxxas Slash (2wd)

For the software, I just played around with samples for Servo control and the 1Sheeld orientation sensors until I got a good understanding of how everything operated.

To prepare the Traxxas Slash, I removed the waterproof cover from the receiver and disconnected the two cables (steering servo and electronic speed control).  It was very simple, and I can return it back to R/C mode very easily once I am done.  I then mounted the breadboard with the breadboard power supply on the Slash chassis, and also put the UNO + 1Sheeld on the breadboard using a rubber band to keep things in place.  After that, I just had to connect my setup.

WARNING: For normal servos, you would connect the red cable from the servo to your + voltage however with an Electronic Speed Control the unit typically does not need power (since it is connected to the battery).  In fact, on my unit the ESC was providing 6V on the red wire so if you did connect that to your 5V supply bad things could happen.

Close up of breadboard with components

R/C receiver with one of the servo cables removed

Shot of the entire setup Once the software + hardware was ready, I turned on the breadboard power supply but left the Electronic Speed Control (ESC) off.  This would allow me to test the steering without the truck moving.  The steering seemed to work fine, not as smooth as the regular R/C setup but not bad.  Next, I turned on the ESC and tilted the phone to confirm the wheels got power.

After I confirmed everything was working, I did a quick test inside the house and then took it outside to play around.  It was pretty neat being able to just tilt the phone to control the truck.

Here is video of the truck running:

https://www.youtube.com/embed/Aca1-zJ74x8

Code

Untitled fileArduino
#define CUSTOM_SETTINGS
#define INCLUDE_ORIENTATION_SENSOR_SHIELD

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

// Create two servo objects
Servo myservo; 
Servo myservo2;

// Setup a few variables
int posY = 90;   
int posZ = 90;
int posY2 = 90;
int posZ2 = 90;

void setup()
{
 // Attach servo objects to output pins
  myservo.attach(9);  // Steering server
  myservo2.attach(10);  // Electronic Speed Control (ESC) for motor

  OneSheeld.begin();
}

void loop()
{
// Pull in Y/Z values for orientation sensor, constrain them to certain limits
  posY2 = constrain(OrientationSensor.getY(), -40, 40);
/* I turned the phone left/right, and figured that it was going -40 to 40 degrees
 * Your device may have different values.
 */
  
  posZ2 = constrain(OrientationSensor.getZ(), 0, 70);
// Phone flat = 0
  
  posY = map(posY2, -40, 40, 145, 35);
  posZ = map(posZ2, 0,70,90,135);
/* Used the map function to tie the orienation sensor ranges to servo position values
 * Servo position values are 0 to 180
 * For steering (posY) I used 35 to 145, which seemed to be the limits of the steering setup
 * For motor (pos Z) I used 90 to 135.  This is basically 0 to 50% power, no reverse/brake
 */

 // Sent position to servo
  myservo.write(posY);  
  myservo2.write(posZ);
  delay(5);
}
Untitled fileArduino
#define CUSTOM_SETTINGS
#define INCLUDE_ORIENTATION_SENSOR_SHIELD

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

// Create two servo objects
Servo myservo; 
Servo myservo2;

// Setup a few variables
int posY = 90;   
int posZ = 90;
int posY2 = 90;
int posZ2 = 90;

void setup()
{
 // Attach servo objects to output pins
  myservo.attach(9);  // Steering server
  myservo2.attach(10);  // Electronic Speed Control (ESC) for motor

  OneSheeld.begin();
}

void loop()
{
// Pull in Y/Z values for orientation sensor, constrain them to certain limits
  posY2 = constrain(OrientationSensor.getY(), -40, 40);
/* I turned the phone left/right, and figured that it was going -40 to 40 degrees
 * Your device may have different values.
 */
  
  posZ2 = constrain(OrientationSensor.getZ(), 0, 70);
// Phone flat = 0
  
  posY = map(posY2, -40, 40, 145, 35);
  posZ = map(posZ2, 0,70,90,135);
/* Used the map function to tie the orienation sensor ranges to servo position values
 * Servo position values are 0 to 180
 * For steering (posY) I used 35 to 145, which seemed to be the limits of the steering setup
 * For motor (pos Z) I used 90 to 135.  This is basically 0 to 50% power, no reverse/brake
 */

 // Sent position to servo
  myservo.write(posY);  
  myservo2.write(posZ);
  delay(5);
}
Codebender

Schematics

Project Diagram
1sheeld slash bb

Comments

Similar projects you might like

4x4x4 LED cube with Arduino Uno and 1sheeld

Project tutorial by Hassan Ibrahim

  • 29,724 views
  • 6 comments
  • 60 respects

1Sheeld CanSat

Project tutorial by Fatima Fouda

  • 4,559 views
  • 0 comments
  • 20 respects

Controlled Board Eraser using Arduino and 1Sheeld

Project in progress by Mahmoud Ayad

  • 7,125 views
  • 3 comments
  • 32 respects

Analog Clock using 1Sheeld Graphical LCD

Project tutorial by Ahmed El-Hinidy

  • 2,069 views
  • 0 comments
  • 7 respects

Automated Photo Booth using Arduino and 1Sheeld

Project in progress by Ashraf Nabil

  • 3,458 views
  • 0 comments
  • 11 respects

Bluetooth Steering wheel for a robot using 1Sheeld

Project tutorial by Kristian Blåsol

  • 2,731 views
  • 1 comment
  • 13 respects
Add projectSign up / Login