Arduino Powered by Your SmartPhone (using SERIAL ) - Part 1 - Sound and Vibration Actions




Introduction: Arduino Powered by Your SmartPhone (using SERIAL ) - Part 1 - Sound and Vibration Actions

Welcome to the first part of this series.In this series we will try take out as much as we can from you smartphone ( android currently ) to your microcontroller using serial cable ( OTG cable ) .

In this part we will explain how you can play some sounds/songs (any mp3 file ) as well as using vibration from your device controlled by your microcontroller ( Arduino ) using only a serial cable ( OTG cable ).

NOTE: No need for Audio shield neither the vibration only your smart phone .this is the purpose of the app.

The Result of this tutorial will be :

So What you will learn from this instructable :

-Serial Communication between Arduino and android ( No Shield !! )

-Using Terminal to view the data ( Serial Inspector in your Mobile )

-Play Audio Files (Mp3 ) controlled from your arduino using serial communication

-Vibrate your device from your arduino using serial communication

-Theory behind the push button (looks simple ha ? :D ) and using of the bounce2 library

To support this project please :
Like our page :

Rate our app :

Difficulty : easy

Expected Time : 1 hour

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Tools You Need

Here is the things you need to have before start with this instructable :

1-Arduino Uno (or any type of arduino even you can choose any microcontroller !! with serial support ) with its usb cable : You should have this already :D.

2-Android Device (running 3.1 and higher ) .

2-OTG cable : This one can be found in any store for computers or electronics .If you have no idea what is OTG cable then check this image .Simply , It allows USB devices such as mobile phones to act as a host, allowing other USB devices like a USB flash drive, digital camera, mouse, keyboard or microcontroller ( e.g arduino ) to be attached to them.

So they will be powered from this host ( smartphones ) as well as receive and send data from the host (smartphones )

3-push buttons (5 items)

4- 10K Ohms resistors ( 5 items)

5- wires

6-cup of juice :D

Step 2: Connecting and Testing (Terminal)

First of all download the application from here.Then connect the OTG cable form one side with the arduino and from other side with you android device .

Before we start adding some actions ( playing sound ,vibration ..etc ) we will start with the testing that everything is going fine .To do that watch the next video :D :

Yes this is a Serial inspector in your device !!

Step 3: Connecting the Components

If you have the previous mention items then connecting them is fairly simple see the Next video :

The Sketch above give a good idea on how the connection can be made.

In general the button has two legs ( or fours ) the first one leg ( or first pair of leg ) are connected to 5 voltage while the other is connected to ground through 10K resistor as well as to the one of I/O pin from arduino.

Don't worry there is no risk in this tutorial :D .

Step 4: Arduino Code - Push Buttons Theory

Upload the attachment (thie code ) in this step to your arduino.

For The code now . Actually it is a simple one I have attached the code and it is well documented.

However,I will go through some basic stuff that may seems a bit difficult :

The idea of this code is whenever you press a button a data ( you can change it ) will be sent from Arduino through serial to your device.there is no problem right ?

Ok the only the problem is that when you push the button it will not go from low state to the high state immediately (or the opposite ) .There will be a period of time where it will hesitate between high to low state so in a nutshell when you press the push button it may send the data twice or more !! .

There are two solutions for this issue one by hardware (using capacitor ) and the other through Software .

In this part we only using software one ( the easy one ) .Now the idea of software solution is to wait a period of time ( the hesitation time ) while the button settle in (become stable) .But we have 5 buttons !! cool down we don't have to write that much of code there is a library for that called bounce2 :D.See this link to download.

So how to use this library, that's the easy part :

// Instantiate a Bounce object
Bounce debouncer1_On = Bounce();

// initiate the button


// Activate internal pull-up


// After setting up the button, setup debouncer


Now you are ready whenever you want to read the status of the button just do :


then read the status :

btn1On =;

after that, depending on the btn1On value ,you send the data.For example when the state is low btn1On==LOW then send #pIntro; ( this string will be translated by the app and it will play specific sound later on this subject )

You may notice we have a variable called preStatus for each button this one is to save the previous status of the button .

If you have more questions about the code please contact me on :

Or discuss it on fb page :

Reference : For more information about Debouncing this video explain a lot :


Step 5: Adding Actions ...

If you didn't yet download the application then download it from here :

what we mean by action is the thing that will handle the data you send from arduino and then will do an action.So for example if you defined a sound action that will be played when the app receive the string #pIntro; from arduino then when the arduino send #pIntro; string the app will pass this string to the action that can handle it in our case is the sound action.

The next video will explain how to add these actions in detail :

Step 6: The Result : Lets Play Some Music !

The result of your work will be in this Video :D as in the introduction

Step 7: In the End :D

Hope you enjoyed this instructable for more info please contact us on

To support this project please :

Like our page :

Rate our app :

Future Parts will include :

- Controlling a motor ( direction + speed ) using configurable buttons.

- Accelrometer (from your device ) controlling 3 leds through Arduino

-Light up a lamp at specific time of day.

-Sending SMS when the light is off or the temperature is high :D

-some cool stuffh

Thanx :D

BlueAct Team.

Tech Contest

Participated in the
Tech Contest

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    8 Discussions


    3 years ago

    Great tutorial !
    BTW im having problem compiling the code
    "Error compiling for arduino/genuino uno"

    It said that no such file or directory #include


    Reply 3 years ago

    Can i have your android source code...


    4 years ago


    Great project. I can't seem to get this to work with arduino uno and Samsung Galaxy Note 3 running 5.0 version. I've confirmed it does have usb host. I get failed because no device found when trying to connect serial. Any ideas?


    5 years ago

    Cool ! When I read the title I thought it would need Bluetooth shields and all those but I'm glad it didn't .

    ram mere
    ram mere

    Reply 5 years ago on Introduction

    Yes I should modify the title a little bit :D


    5 years ago on Introduction

    Now you have 24 more views.

    Nice clean graphics.

    If you are looking for traffic try adding a pic that Google adds to their search engine, look on Google under iron penny

    ram mere
    ram mere

    Reply 5 years ago on Introduction

    Yes.But still my instructable is stuck in their filter ! :$ . It is now shown in recent neither when you search for it . it is like I never publish it . Hope they solve this issue soon and publish mine.


    Reply 5 years ago on Introduction

    Published. You used the f word too many times. "Facebook" trips the filters.