Control Electronics by Sliding Your Phone

32,448

483

18

Introduction: Control Electronics by Sliding Your Phone

About: I'm from India and love making projects on electronics, specially with arduino. Internet is the only guidance I have and I've been into these since I was 11.

This instructable will take you to through the fun when power of RF, android smartphone and arduino are combined.

To adjust the brightness of your table lamp/lights in studio if you are a photographer, speed of ceiling fan, adjust the volume of your home theater, or to control the speed of motor, you have to adjust the potentiometer/dimmer or slide something, but can you do those things with any smartphone/tablet?

Well, the answer may be yes, nowadays home automation via internet/bluetooth/WiFi are very popular all you need to do is turn on your PC or phone and send some values or adjust any slider, you can also buy several home automation products from market, but the way you are going to see in this instructable is one of a kind and none of the automation companies have it till now, also it is much more simpler than anything you saw when it comes to automation.

You just need to slide your android smartphone/tablet, no need to unlock it no need to adjust any slider just keep your phone on the table and rotate it.

Lets Get Started

Step 1: Materials Required

https://www.utsource.net/is an online platform for technicians, Makers, Enthusiasts, Kids to buy electronic components

1.) 1sheeld

2.) Arduino

3.) USB for Arduino

4.) Android smartphone with orientation capability

5.) An LED

6.) Resistor any will work < 1K

7.) Arduino IDE installed in your PC

You can jump to step 5 if you know about 1sheeld and already installed its library

Step 2: About 1SHEELD

Here introduction to 1sheeld becomes important if you do not know about it, as it runs the complete project.

If you know about the Arduino and its shields like GSM and WIFI, and also buying each of them for use is expensive. To replace them all with just one, the Egyptian inventors made a wonderful single shield which connects to your android smartphone via Bluetooth and uses all the sensors and connectivity of it. You can also use more than one shield at a time like GSM, WIFI, Accelerometer, Gyroscope etc.

1sheeld - http://www.1sheeld.com/

Step 3: Place Your 1sheeld Correctly

You need to place your 1sheeld correctly, confusion can arise while using with Arduino Mega.

Step 4: Download 1sheeld Library

You need to download and place 1sheeld library from here- https://github.com/Integreight/1Sheeld-Arduino-Lib...

And then extract it to the location in libraries of arduino.

Step 5: The Code

Open arduino IDE then copy and paste this code.

The code is based simple analogWrite command.

I'm not a good programmer at all, I'm still in 11th grade and have to concentrate on my academics/school so I cant spend much time learning coding, and previous program( Which I've removed) was very long and not so good but then I got much more Improved code from Manick Yoj in the comment section and I replaced my code with new one.

#include <OneSheeld.h>

int ledPin1 = 11;

float xOrientation;

void setup() {

/* Start communication. */

OneSheeld.begin();

pinMode(ledPin1,OUTPUT);

}

void loop() {

// Check X-axis orientation.

xOrientation = OrientationSensor.getX();

// Map orientation to brightness

if(xOrientation < 102) analogWrite(ledPin1,xOrientation * 2.5); // Or turn off the LED if the orientation is > 125 degrees

else analogWrite(ledPin1, 0);

}

Step 6: Upload the Code

Open arduino IDE then copy, paste this code and then upload.

Step 7: Download 1sheeld App

Download it from Playstore, open it, turn the Bluetooth on, connect to the 1sheeld and then select the Orientation Shield.

Step 8: Solder the Resistor to Led

Solder the resistor to led and then attach the led to arduino to pin no. 11. ( you can change the pin number in the code)

Step 9: Further Uses

You can see the real time working in the video

Now its up to you what you want to control, for example if you want to turn the lights on and of you can use relays, if you want to adjust the brightness of the lamp you can make a dimmer with MOSFET as shown in this instructable so with that you will be able to control the speed of ceiling fan, high power halogen or heater.

Be careful while connecting any inductive load on the circuit, do not forget to use a Flyback diode while doing so.

Thank you

Tanishq Jaiswal

Soldering Challenge

Participated in the
Soldering Challenge

Phone Contest

Participated in the
Phone Contest

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    18 Discussions

    0
    dhongalepankaj
    dhongalepankaj

    3 years ago

    I like your work , your idea is very unique and creative . i would also like to work on this project. i am having a problem with the application and other uses of it and even i don't found it on google , Do you have any extra information about this project , it would help me to make it complete.

    0
    Tanishq Jaiswal
    Tanishq Jaiswal

    Reply 3 years ago

    Please elaborate your problem.

    0
    Geethika Manam
    Geethika Manam

    4 years ago

    Is the code appropriate for controlling brightness of an LED?

    0
    Manick Yoj
    Manick Yoj

    5 years ago on Step 5

    Tanishq - This is great: I'd never heard of 1Sheeld before but I'm encouraged to use it thanks to your project.

    You mentioned that you would be interested in feedback on your code, and I have one suggestion: your analogWrite commands are all just a straightforward map OrientationSensor.getX() * 2.5. In other words, you could simplify your loop() function down to three lines and have more precise brightness control in the process (unless you want the discrete brightness cutoffs. If you're interested, you could refactor your program to the below. Note that the xOrientation variable is declared up top as well as the changes to loop().

    int ledPin1 = 11;

    float xOrientation;

    void setup() {

    /* Start communication. */

    OneSheeld.begin();

    pinMode(ledPin1,OUTPUT);

    }

    void loop() {

    // Check X-axis orientation.

    xOrientation = OrientationSensor.getX();

    // Map orientation to brightness

    if(xOrientation < 125) analogWrite(ledPin1,xOrientation * 2.5);

    // Or turn off the LED if the orientation is > 125 degrees

    else analogWrite(ledPin1, 0);

    }

    0
    Manick Yoj
    Manick Yoj

    Reply 5 years ago on Step 5

    Oh - I made one silly mistake: any xOrientation value over 102 will cause the analogWrite function's second argument to exceed 255. Instead of

    if(xOrientation < 125) analogWrite(ledPin1,xOrientation * 2.5);

    this should read

    if(xOrientation < 102) analogWrite(ledPin1,xOrientation * 2.5);

    0
    Tanishq Jaiswal
    Tanishq Jaiswal

    Reply 5 years ago on Introduction

    Brother, Thank You Very Much for making it somthing more than perfect! I will change the code and mention you.

    Thanks once again

    0
    Manick Yoj
    Manick Yoj

    Reply 5 years ago on Introduction

    Haha - I'm glad you'll make use of it. You don't need to credit me though. Best of luck with your programming and electrical endevours!

    0
    NeilRG
    NeilRG

    5 years ago on Step 6

    Your approach is inspiring. The shield you used is new to me. This instructable is very well written . Thank you.

    0
    Chrisf2018
    Chrisf2018

    5 years ago

    I'm currently trying to learn the basics of electricity and physics. I would like to know if any one has a good site to get started on learning one of these two.

    0
    dstech
    dstech

    Reply 5 years ago on Introduction

    Hey! http://www.allaboutcircuits.com/textbook/

    allaboutcircuits has a pretty great free online text, that takes you from the very basics up to some pretty advanced stuff and it looks like their new site has some decent articles and a new forum as well

    0
    SLIMDADDYC
    SLIMDADDYC

    Reply 5 years ago

    I'm not 100% sore this will help you but one thing I found helpful and fun was the PHET website https://phet.colorado.edu there are quite a few virtual circuitry programs on their site. Good luck!

    0
    NakulB1
    NakulB1

    5 years ago

    Best one on this Contest bro..!!
    just try and make it on iphone users too...???

    0
    Tanishq Jaiswal
    Tanishq Jaiswal

    Reply 5 years ago on Introduction

    Thank you, NakulB1

    As soon as the app for I phone will be launched I'll add another step for it.

    0
    ZakD
    ZakD

    5 years ago

    Possible on jailbroken iPhone?