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.