I do not get it solved

Hello all,

I’m making something for my airbus project, It is intended for LED lights to turn on and off and to
controll a servo. I made an app in MIT App Inventor 2. The problem is that when I turn on the LED
will also move my servos.

I made a movie with what i mean

my english is so good, especially if we talk technical :s

The led sketch :

int ledpin = 5;
String readString;

void setup() {
 pinMode(ledpin, OUTPUT);

void loop() {
 while (Serial.available()) {
   char c = Serial.read();
   readString += c;
 if (readString.length() >0) {
   if (readString == "a")
     digitalWrite(ledpin, HIGH);
   if (readString == "b")
   digitalWrite(ledpin, LOW);  

The servo sketch :

#include <Servo.h> // servo library 

Servo gaston; // 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

gaston.attach(9);// server is connected at pin 9


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

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

delay(15); }


I can not find on the Internet that they work separately from each other,
there is something they both respond to, perhaps from app inventor.

I appreciate it if someone knows a solution

I appreciate it if someone knows a solution

The LED code can not possibly move the servos. The servo code can not possibly be impacted by the LEDs.

You obviously have other code that combines the two sketches, and that code is the code that is not doing what you want. Trot that code out for us to look at.

true, it is also the servo sketch I uploaded, and when I push the button the servo then moves. but it is to turn on the LED.

these two sketches, I must merge. I can do that too

Short answer, no solution offered:

The Servo sketch will react to the LED commands sent from App Inventor because Serial.read() will return the values 79 and 110 - the ASCII codes for "On".

This Simple Merge Demo may help.

And please make it easy for people to help you by modifying your post and using the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum


thx [u]Robin2[/u], I've just fixed it, That with that code. two or three hours! I've done spend days, no almost a week researching, i will check and read the your link But it's all....中文對我來說,所以我不明白 Google translate ----> Chinese for me so I do not get it ;)

But what [u]Martin-X[/u] says, I think that's where my problem, of course also Merging the code. First,, i figure out the merging code. Maybe in the forum of MIT app inventor, they know that.

Really difficult