Project tutorial

Pan-Tilt Controlled by Cell Phone © CC BY-NC-ND

This project is about a Pan-Tilt controlled by cell phone via Bluetooth and using 1Sheeld.

  • 9,029 views
  • 1 comment
  • 39 respects

Components and supplies

Apps and online services

About this project

Introduction

In this project I will introduce to you a pan-tilt controlled by cell phone.

All movements of the cell phone are reproduced in the pan-tilt device via Bluetooth. The assembly is very simple using an Arduino R3 (or similar) and two shields over it.

I started this project thinking about a device to support newbies in home astronomy giving them an easy way to indicate the right position for the telescope to find out in the sky any planet, star or constellation.

You just need use this device as a sky pointer together with apps like Sky Map.

Very easy and fun!

Video

Material list

All you need is on the following list:

  • Arduino Uno R3 (or similar)
  • 1Sheeld - Android version (shield for connection to cell phone - Android)
  • Motor Driver Shield (for servo motors)
  • 02 x Micro Servo Motors SG90 (or similar)
  • Pan-Tilt SG90 kit
  • Power supply (9V x 1A) with plug P4
  • USB cable (connection between Arduino and your Computer)

Assembly

The assembly is very simple with no soldering and few wirings.

Follow the next steps:

  • Put 1Sheeld board over the Arduino board.
  • Put the Motor Driver Shield over the 1Sheeld board.
  • Connect the cable of Tilt axis in the Motor Shield plug (Servo 1).
  • Connect the cable of Pan axis in the Motor Shield plug (Servo 2).

1Sheeld

According with their developers, "1Sheeld turns your smartphone into 40 different Arduino shields".

This shield is very interesting because you can connect an Arduino board via Bluetooth to a cellular phone and use all its available sensors. The connection is simple and you have all necessary libraries available for Arduino. In this way you can reduce the time you need for your prototypes and decide if you want go ahead or if you need to update something.

After final results you can convert the prototype on a final product applying traditional components and sensors.

For the first use of 1Sheeld you need to download its library to the folder where the Arduino IDE is installed in your computer and in your cell phone you need to install the 1Sheeld App (for Android) or 1Sheeld App (for iPhone).

Remarks:

  • 1Sheeld can run in background and then you can run also another app simultaneously.
  • If you want more information about this shield, visit the 1Sheeld site.

Programming and Setup

The program is very simple.

With the library of Orientation of 1Sheeld, the Arduino program will read the axis X and Y of your cell phone and translate them to the angular position of each servo motor.

One important detail is each cell phone can have a different origin/reference for the axles X, Y, Z.

Due to this I have put an statement on setup routine of Arduino to make the "zero" reference according with the positioning of you cell phone.

At start, you need to put the cell phone on horizontal position aligned with the Pan-Tilt device and then press the reset button of Arduino (you also can press the reset button of the Motor Shield because it is on the top with an easier access).

After this step the Pan-Tilt is already referenced to follow the position of your cell phone!

Move the phone and see the corresponding movements into the servos.

Code

Pan_Tilt_controlled_by_Cell_Phone.inoArduino
Code for Arduino UNO
/*
  Project:    Pan-Tilt Controlled by Cell Phone
  Author:     LAGSILVA
  Hardware:   Arduino UNO-R3 / 1SHEELD
  Date:       14.Feb.2016
  Revision:   1.0
  License:    CC BY-NC-ND 4.0
              (Attribution-NonCommercial-NoDerivatives 4.0 International)
  -----------------------------------------------------------------------
  Notes:
  1.  Application supported by 1SHEELD-Android for Arduino UNO
  2.  X-axis ranges from 0 to 360 degrees
  3.  Y-axis ranges from -180 to 180 degrees
  4.  Z-axis ranges from -90 to 90 degrees.
  -----------------------------------------------------------------------
*/

#define CUSTOM_SETTINGS
#define INCLUDE_ORIENTATION_SENSOR_SHIELD

#include <OneSheeld.h>    // Include 1Sheeld Library
#include <Servo.h>        // Include Servo Library

Servo myservoX;           // Create servo object to control Orientation X
Servo myservoY;           // Create servo object to control Orientation Y

float angleX, angleXi, angleY;
float angleYi = -35;      // This value must be set with a trial to align the "zero" angle of your Tilt. In my case I used -35 for compensation.
boolean k = true;

void setup()
{

  OneSheeld.begin();
  OrientationSensor.setOnValueChange(readAngleXi);

  myservoX.attach(9);    // Servo2 (in the Motor Shield) of Axix X (PAN)  - connected to Analogic Pin 09 of Arduino
  myservoY.attach(10);   // Servo1 (in the Motor Shield) of Axix Y (TILT) - connected to Analogic Pin 10 of Arduino

}


void loop()
{

  angleX = -OrientationSensor.getX();
  angleX = angleX - angleXi + 90;
  if (angleX < 0) {
    angleX = angleX + 360;
  }
  if (angleX > 360) {
    angleX = angleX - 360;
  }
  angleX = constrain(angleX, 0, 180);

  myservoX.write(angleX);
  delay(15);

  angleY = -OrientationSensor.getY();
  angleY = 180 - (angleY - angleYi);
  angleY = constrain(angleY, -30, 150);
  myservoY.write(angleY);
  delay(15);

}

void readAngleXi(float xAxis, float yAxis, float zAxis)
{
  if (k) {
    angleXi = -xAxis;
    k = false;
  }

}

Comments

Similar projects you might like

Voice Controlled Robot using your Smart Phone

Project tutorial by Ahmed Yassin

  • 3,058 views
  • 0 comments
  • 7 respects

Android Controlled 6DoF Robotic Arm

Project in progress by Team Mans

  • 11,065 views
  • 0 comments
  • 17 respects

Robotic Car Controlled over Bluetooth by Andriod Phone

Project showcase by S.Ranjith Reddy

  • 4,431 views
  • 0 comments
  • 9 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 35,275 views
  • 4 comments
  • 55 respects

Solar Panel Sun Tracker - Phone Charger

Project tutorial by FIELDING

  • 27,320 views
  • 11 comments
  • 119 respects

How to Make a Remote Controlled Robotic Hand with Arduino

Project showcase by Gabry295

  • 35,364 views
  • 5 comments
  • 110 respects
Add projectSign up / Login