How to move the servo without interrupt DHT11 for Visual Basic

hi, so i’m working on a new project for my class. im really new to arduino programming, and this program is for visual basic 2010 Express.

I want this program to be able to read DHT11 continuously, and at the same time I can move the servo (in visual basic I use trackbar).

but the program that I made sadly works like this:
when the servo given a command to moves (for example to an angle: 180) it will moves to angle 180, but then a few seconds later it will return to its original position (angle: 0) without any command.

so the question is, how to correct this program so that the servo does not return to the initial position before it is given a command to angle 0, while at the same time the program is reading the sensor?

I have no idea how to write/correct it, please help me… thanks a lot!

p.s. I use google translate, but i hope it still understandable for you

this is the program:

#include "DHT.h"
#define DHTPIN 12    
#define DHTTYPE DHT11   // DHT 11 
#include <Servo.h> 
 
Servo myservo;  
DHT dht(DHTPIN, DHTTYPE);

int data[3] = {0,0,0};
int pos = 0;

 
String TextForSms ;
String humidity = " Humidity: %";
String temperature = "   Temperature";
String sign = " *C";
 
char fromc; // character from computer
 
void setup() {
  Serial.begin(9600); 
  dht.begin(); //dht11 : pin 12
  myservo.attach(9);  // servo : pin 9 
  myservo.write(2);
}
 
void loop() 
 { 
  delay(200); //DHT 11 program
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  int f = dht.readTemperature(true);
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
 
  int hi = dht.computeHeatIndex(f, h);
 
  TextForSms = TextForSms + t + "," + h + ","; 
  Serial.println(TextForSms); 
     TextForSms = ""; 
   delay(1000); 

  
Serial.available()==0; { //servo program
  }
pos=Serial.parseInt(); 
myservo.write(pos); 
 delay(25);

}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Serial.available()==0; { What’s that for?

Please remember to use code tags when posting code

Other threads removed.

thankyou so much! i wont do such thing again

hello, this problem is finally solved after so much trial-error and i tried any kind of possibility, because i'm really new in arduino.

so, in case anyone has the same problem like me, here is the last line code that already changed:

int pos;
if (Serial.available()) {
delay(100);
while(Serial.available()>0) {
pos=Serial.parseInt();
myservo.write(pos);
pos=" "; } }

thankyou so much!

  if (Serial.available()) {
    int pos=Serial.parseInt();
    myservo.write(pos);
}

pos=" "; Have a good long think about that.

Please remember to use code tags when posting code

c_hyemiiiii:
hello, this problem is finally solved after so much trial-error and i tried any kind of possibility, because i'm really new in arduino.

You forgot your [​code][​/code] code tags again, didn't you?

The while is unnecessary once you've already checked Serial.available(). I removed it.
No idea what purpose the delay serves. I left it in just in case.
Variable "pos" is an int. What the heck is assigning a string to it with pos = " " supposed to do?

  if (Serial.available()) {
    delay(100);
    int pos=Serial.parseInt(); 
    myservo.write(pos); 
  }