Introduction: Arduino, MIT App Inventor Servo Motor Controller

Picture of 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

Picture of 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

Picture of 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

Picture of 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!!

Picture of 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:

Comments

LorisD1 (author)2017-10-14

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

LorisD1 (author)LorisD12017-10-15

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

gunaed (author)2016-04-29

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

taa4 (author)2016-01-06

great work

Roentgenium111 (author)2016-01-05

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

makeosaurus (author)2016-01-04

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

halim930112 (author)makeosaurus2016-01-04

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

halim930112 (author)halim9301122016-01-04

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

makeosaurus (author)2016-01-04

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

About This Instructable

9,795views

44favorites

License:

More by halim930112:Arduino Systems: Simple Bluetooth Door LockVoice To Arduino: Control LEDs using MIT Speech RecognizerExperiment for Fun: Morse Code Encrypter Using Arduino and Smartphone!!!!
Add instructable to: