Servo vibrate and move by itself if use SIM900A

Hi…

Actually i have been making system tracking used PIR sensor, Servo, and SIM900A

i used 2 PIR sensor

  • PIR1 i put at 0 degree
  • PIR2 i put at 180 degree

So when human movement detected, servo will move to source human movement, then SIM900A make call. i have done for it all. PIR sensor can track and SIM900A success for calling

But the problem is why my servo is vibrate and move by itself ? if without use SIM900A, servo and pir working normally. is it anything wrong?

Code :

#include <Servo.h>
#include <SoftwareSerial.h>

SoftwareSerial SIM900A (5,6);
Servo myservo;

int curPosPir1 = 0;
int curPosPir2 = 180;

int val = 0;

int pinPIRleft = 3;
int pinLEDleft = 12;

int pinPIRright = 4;
int pinLEDright = 13;

int pinBuzzer = 10;
int expected_pos;
int incr;
int pos = 0;

void setup() {
Serial.begin(9600);
SIM900A.begin(9600);
delay(100);
myservo.attach(9);
pinMode(pinPIRleft, INPUT);
pinMode(pinPIRright, INPUT);
pinMode(pinLEDleft, OUTPUT);
pinMode(pinLEDright, OUTPUT);
pinMode(pinBuzzer, OUTPUT);
}

void loop() {

if (digitalRead(pinPIRright) == HIGH) {

digitalWrite(pinPIRleft, LOW);
digitalWrite(pinLEDright, HIGH);
SIM900A.println(“ATD +xxxxxxxxx4422;”);
delay(100);
playTone(400, 500);
delay(5);
expected_pos = 0;
curPosPir1 != pinPIRright;

} else {
playTone(0, 0);
delay(100);
digitalWrite(pinLEDleft, LOW);
digitalWrite(pinLEDright, LOW);
}

if (digitalRead(pinPIRleft) == HIGH) {
digitalWrite(pinPIRright, LOW);
digitalWrite(pinLEDleft, HIGH);
SIM900A.println(“ATD +xxxxxxxxx4422;”);
delay(100);
playTone(400, 500);
delay(5);
expected_pos = 180;
curPosPir2 != pinPIRleft;

} else {
playTone(0, 0);
delay(100);
digitalWrite(pinLEDleft, LOW);
digitalWrite(pinLEDright, LOW);
}

I have used 9600 and 38400.
it success for calling, but make servo vibrate and move by itself and never stop.
it can be stopped if SIM900A is disconnected and erase command for call “SIM900A.println(“ATD +xxxxxxxxx4422;”);”

can anyone help me to solve it?
Apreciate for your replying.
Thanks.

Marveyy:
is it anything wrong?

The usage of “#include <SoftwareSerial.h>” is wrong in any program that uses interrupts with tight timing requirements.

For best servo pulse timing you’d better use an Arduino board which provides more than just one hardware serial port and use the additional hardware serial ports for serial communication.

For example, a MEGA2560 also provides Serial1, Serial2 and Serial3 to communcate with serial devices.

jurs:
The usage of “#include <SoftwareSerial.h>” is wrong in any program that uses interrupts with tight timing requirements.

Hi jurs, thanks for suggesting…

for “#include <SoftwareSerial.h>” i just used it for activate SIM900A to make a call (working normally)

i also have separated with external power supply for SIM900A, but servo still shakes

my observation is if servo combine with SIM900A, it will make servo shakes constantly.

i used servo SG-90.

is it possible if used plastic nilon gear will become shake?

should i change new servo with metal gear?