Arduino, MIT App Inventor Servo Motor Controller

20,465

46

14

Introduction: Arduino, MIT App Inventor Servo Motor Controller

Hello again everybody!! I hope all of you are fine and in good mood and condition always. Today I would like to share my experiment on using the MIT appinventor on controlling servo motor attached to arduino. Well, wait a minute, my experiment before this also use appinventor, sooooo what's the difference?

Well, the difference is that in this experiment I am going to use the slider function in the appinventor as opposed to the experiment before, where I only use button functions.There will be two parts in the instructables, arduino part and the appinventor part. So let's get started shall we?

Step 1: Step 1: the Items Needed

As usual, I am going to list all the items that is needed for this experiment.

Hardware:

1. Arduino UNO

2. Servo motor

3. Bluetooth module ( HC-05 or HC-06)( i am using HC 06)

4. Male to male jumper wire

5. Breadboard

6. Android smart phone

Software:

1. Arduino IDE

2. MIT app inventor

Step 2: Step 2: the Appinventor Design and Blocks

Alright in the first image, which is the appinventor design screen, there are the slider object, the list picker and so on.. I would like to stress some information on the slider object.

If you look at the properties panel at the right when selecting the slider, you could see some variables you can edit. In this experiment, I would like my servo to turn from 0 to 180 degrees. That is why i have decided my minValue to be 0 and maxValue to be 180.

You can also customize the width of the slider by adjusting the width variable in the properties panel. I also wanted my initial position of my slider to be at the middle (90) therefore, I adjusted the thumb position variable to 90.

The second image shows the code block for the experiment.Notice that in the code block, I had initialized my global value ( thumb position) to 90.

Step 3: Step 3: Arduino Code

#include< Servo.h >// include server library

Servo ser; // create servo object to control a servo

int poser = 90; // initial position of servo

int value; // initial value of input

void setup()

{

Serial.begin(9600); // Serial comm begin at 9600bps

ser.attach(7);// server is connected at pin 7

}

void loop()

{

while(Serial.available()) //read while data is present

{

value = Serial.read(); //value = serial read data from phone

poser = value ; //than position of servo motor equals to value of data read from phone

ser.write(poser);// the servo will move according to position

delay(15); }

}

Step 4: Step 4: Assemble the Circuit and Test It!!

The circuit is assemble as shown in the sketch. The sketch is made is using fritzing. During uploading the code into arduino, make sure the bluetooth RX and TX to arduino were disconnected first from TX and RX of arduino. That's all for the circuit assembly.

Now everything is set up. Download the the code you made in appinventor to your phone (save .apk in computer, then transfer it to your phone). Upload the arduino code and test it!! The link for demonstration video is here:

Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest

Be the First to Share

    Recommendations

    • Mason Jar Speed Challenge

      Mason Jar Speed Challenge
    • Bikes Challenge

      Bikes Challenge
    • Remix Contest

      Remix Contest

    14 Discussions

    0
    Kamiikaze
    Kamiikaze

    Question 2 months ago on Step 1

    hello, loved this instruction, just have a question, in the code how can i controle 5 servos and 2 micro servos. Once again thank u so much

    0
    Kenny-Tech
    Kenny-Tech

    7 months ago

    Hi, please aim amater. You can help me, im not find flag (in mit block) in arduino code? Whats is flag in mit its in arduino code?

    0
    RatkanokP
    RatkanokP

    Question 1 year ago

    I want library servo.That you use in Arduino.
    Pleaseee. Thank You

    0
    freed54
    freed54

    Question 1 year ago on Introduction

    Thank you first or this instructable , I'm just going to be learning about Arduino, could you please give me a part number or description for the board I need ? also part number for servo motor ? Thank you in advance !

    0
    LorisD1
    LorisD1

    2 years ago

    Le contrôle d'un servo fonctionne parfaitement.
    Je dois réaliser un projet comportant 4 servos et je ne parviens pas à attribuer un curseur à chacun des servos, il y a surement quelque chose qui m'échappe dans le code, soit appinventor ou arduino

    0
    LorisD1
    LorisD1

    Reply 2 years ago

    Après quelques essais, j'ai trouvé la solution pour gérer plusieurs servos

    0
    gunaed
    gunaed

    4 years ago

    i allready to the same but it dose not work can you help me please :(

    0
    taa4
    taa4

    4 years ago

    great work

    0
    Roentgenium111
    Roentgenium111

    4 years ago

    What does the MIT App Inventor do? Is it just a simpler way to get code?

    0
    halim930112
    halim930112

    Reply 4 years ago

    The MIT app inventor is an android app maker. Usually people use Android SDK for developing complex apps for android based smartphones. The MIT simplifies some of the app making by providing block based coding (similar to scratch). So, it can be said that the MIT app inventor enables user to develop some apps easier and faster. There are a lot of tutorials for MIT app inventor. You can go to this website to explore the appinventor:

    http://appinventor.mit.edu/explore/tutorial-version/app-inventor-2.html

    1
    makeosaurus
    makeosaurus

    4 years ago

    However don't you need a motor driver shield to run the servo so you don't damage your arduino?

    0
    halim930112
    halim930112

    Reply 4 years ago

    In my opinion, my friend. the motor driver shield is used to run bare motors(DC stepper motor), while the servo had already been equipped with drive electronics and we need to just give it signal for it to function. You can also refer to the forum here for more info:
    http://arduino.stackexchange.com/questions/11592/d...

    0
    halim930112
    halim930112

    Reply 4 years ago

    But however, if you want to use a number of servos, it is better to use the shield.

    0
    makeosaurus
    makeosaurus

    4 years ago

    Nice instructable!! Going to buy myself a hc-06 and some servos now!!