Using 1Sheeld, remote control an Arduino powered vehicle with the accelerometer in your Smartphone/Tablet.
Step 1: Essentials
You will require the following items, or equivalent.
1) Any Arduino powered vehicle platform. Pictured is the Dagu Wild Thumper 4WD with Sabertooth Dual 25A 6V-24V Regenerative Motor Driver.
2) Power. Pictured is a 6V 10000mAh Rechargeable NiMh Battery with Smart Charger. The size and weight of this pack makes it unsuitable for smaller vehicles, but is perfect for a larger platform such as the Thumper. Using Mini Tamiya Connectors makes connecting your battery pack to your motor driver a little easier.
3) 1Sheeld and Android Smartphone/Tablet
4) SeeedStudio 3 Pin Ultrasonic Range Finder (optional). The 3 pin is better than the available 4 pin sensors because it frees up a pin on your Arduino platform.
All items available at RobotShop
Step 2: Build Your Vehicle
Since this project is not really specific to any vehicle platform, I'll leave it to you to build your own vehicle. Many kits are available, you could build your own from scratch using another Instructable, or your could redeploy a platform you already have.
The Dagu 4WD Wild Thumper is a heavy duty platform that is robust enough to support future projects. Pictured is my "MALP" with a LynxMotion AL5D Robotic Arm on top and a Dagu 2 Degrees of Freedom (2DoF) Robot Arm & Gripper on back.
Visit YouTube to see various videos of the Wild Thumper in action. Provided videos presented here are not my project, but also sourced from YouTube.
Step 3: 1Sheeld Explained
1Sheeld Android Smartphone Multi-Purpose Shield is an easily configured shield for Arduino. It is connected to a mobile app that allows the use of all of Android smartphones' capabilities such as LCD Screen, Gyroscope, Switches, LEDs, Accelerometer, Magnetometer, GSM, Wi-Fi, GPS …etc. into your Arduino sketch.
For more information, visit 1Sheeld Tutorials Archive
Step 4: Sabertooth Motor Driver Explained
The Sabertooth 2X25amp is a versatile, efficient and easy to use dual motor driver. It is suitable for high powered robots - up to 100lbs in combat or 300lbs for general purpose robotics.
The Sabertooth receives power via the B screw terminals, and can power other components via the 5V screw terminal. I did experiment with powering the Arduino from this terminal, but something about the power wasn't "clean enough" ... every time I hammered the throttle to maximum speed, the 1Sheeld would drop the connection. Rather than putting much time into this issue, I just used a separate power source for the Arduino.
Aways ensure the 0V screw terminal is connected to your Arduino ground, otherwise the Sabertooth will not receive control signals from your Arduino.
You can control the Sabertooth via various modes. This project uses Mode 3 Simplified Serial Mode... basically, you send a single byte of data representing a number from a digital pin on your Arduino to the S1 channel on your Sabertooth. In that single byte, you have a range of numbers between 0 (lowest), and 255 (highest)... each number representing a unique motor, direction, and speed setting all in one. The Sabertooth interprets that number and adjusts speed/direction power for either (set of) motors connected to the M1 and M2 screw terminals.
Here is a small code fragment illustrating driving one motor forward 50% and one motor backwards 75%.... 2x4 means 2/4, 1/2, 50% , and 3x4 means 3/4, 75% ...
// Values 1 thru 127 controls Left motor, 128 thru 255 controls Right motor
#define FORWARD_4x4_R_MOTOR 255
#define FORWARD_3x4_R_MOTOR 240
#define FORWARD_2x4_R_MOTOR 224
#define FORWARD_1x4_R_MOTOR 208
#define STOPNOW_0x4_R_MOTOR 192
#define REVERSE_1x4_R_MOTOR 176
#define REVERSE_2x4_R_MOTOR 160
#define REVERSE_3x4_R_MOTOR 144
#define REVERSE_4x4_R_MOTOR 128
#define FORWARD_4x4_L_MOTOR 127
#define FORWARD_3x4_L_MOTOR 112
#define FORWARD_2x4_L_MOTOR 96
#define FORWARD_1x4_L_MOTOR 80
#define STOPNOW_0x4_L_MOTOR 64
#define REVERSE_3x4_L_MOTOR 48
#define REVERSE_2x4_L_MOTOR 32
#define REVERSE_1x4_L_MOTOR 16
#define REVERSE_4x4_L_MOTOR 1
SaberSerial.write( FORWARD_2x4_R_MOTOR ); // 2/4 is 50%
SaberSerial.write( REVERSE_3x4_L_MOTOR ); // 3/4 is 75%
For more details, read the provided PDF documentation, and refer to the provided code later.
Step 5: The Sensor Explained
The ultrasonic sensor operates by sending a short ultrasonic pulse , and measuring the time it takes to receive an "echo" back. The shorter the amount of time, the closer the object.
Using a predefined library (included in provided code), the code to accomplish this is rather simple...
frontRangeInCentimeters = ultrasonicFront.microsecondsToCentimeters();
In the provided code, the ultrasonic sensor is used to override pilot commands to prevent the vehicle from running into a detected obstacle such as a wall. If you chose not to install the sensor, the code can be easily deactivated.
Step 6: The Algorithm - Throttle, Steering
Holding your device straight up will stop (park) your vehicle.
Leaning your device away from you (pitch) will move the vehicle forward... the more lean, the faster.
Leaning your device towards you will move the vehicle backwards... the more lean, the faster.
Rolling your device to the left will steer the vehicle to the left, and right steers right.
You can easily make modifications to the sensitivity of the relationship between the device and the vehicle by making the appropriate code changes in the sketch.
Step 7: The Algorithm - Ignition, Throttle Governor
The 1Sheeld Slider is used as an "ignition switch". The vehicle will not run if the slider is at the lowest setting.
The Slider is also used as a "throttle governor". With it set halfway or less, the vehicle will run at a single moderate speed setting, suitable for beginners. More than halfway, all power settings are available.
The code is easily modified if you wanted to tweak the governor for other power settings.
Step 8: Install Code
I've provided an extensively documented Arduino sketch that provides the functionality as described in the previous steps..
If you've configured your components correctly, it should work as is. Some fine tuning will probably be required. Or, you could hack the code to suit your needs.
Step 9: Your Turn to Code!
With an impressive array of available 1Sheeld controls, you'll have lots of other potential projects for your vehicle.
For more information on the robotic arm, visit my related Instructable 1Sheeld Controlled Robotic Arm