Arduino, MIT App Inventor Servo Motor Controller

28K4719

Intro: 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:

14 Comments

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
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?
I want library servo.That you use in Arduino.
Pleaseee. Thank You
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 !

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

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

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

great work

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

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

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

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...

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

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