Hello everyone...
I'm trying to control 2 servo, one will keep sweeping automatically while the others will change position when i push my transmitter...
I know this need to use interrupt but i cant really understand how to write the program...
I try to write it out & hope someone can point out my mistake...
Thank you very much

Here's my code:
#include <Servo.h>
Servo myservo1; // create servo object to control a servo
Servo myservo2;
int pos = 0; // variable to store the servo position
volatile long transmitterValue; // to store the transmitter position/value
void setup()
{
myservo1.attach(10);
myservo2.attach(11);
attachInterrupt(0, servoPosition, CHANGE); //interrupt function to control the servo position when receive signal
Serial.begin(57600); // to link the board & send the data to computer
Serial.println("Done with setup");
}
void checkTransmitter()
{
transmitterValue = ( pulseIn(2, HIGH, 100000) / 10 ); // Read RC channel from the interrupt pin
}
void servoPosition () // interrupt function
{
if ( transmitterValue < 130 )
{
myservo2.write(30);
}
else if ( transmitterValue > 150 )
{
myservo2.write(150);
}
else
{
myservo2.write(90);
}
}
void sweepingServo()
{
for(pos > 30; pos < 150; pos += 1)
{
myservo1.write(pos);
delay(20);
}
for(pos < 150; pos > 30; pos -= 1)
{
myservo1.write(pos);
delay(20);
}
}
void loop ()
{
checkTransmitter();
sweepingServo();
servoPosition ();
Serial.print("data:");
Serial.println(transmitterValue);
delay(200);
}