Hello! i am facing certain issues with at commands for sim900a module. This is what i am stuck at:
The AT command Serial.write("AT+CPAS); is not returning the status of the call. This is what i want my project to achieve. The led on pin 13 must be on while the call is ringing and as soon as the call is answer, led on pin 13 must stop and led on pin 12 must glow. The problem is the serial is monitor is printing "AT+CPAS" and not returning a value.
This is my code(to call i have also used buttons):
const int tocall = 2; // the number of the pushbutton pin
const int toend = 3;
const int toreceive =4;
int led1 = 13;
int led2 = 12;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int y=0;
void setup()
{
Serial.begin(9600);
delay(1000);
pinMode(led1, OUTPUT);
PINmode(led2, OUTPUT);
}
void loop()
{
buttonState1 = digitalRead(tocall);
buttonState2 = digitalRead(toend);
buttonState3= digitalRead(toreceive);
if (buttonState1 == HIGH) {
Serial.println("ATD8970220880;"); //where xxxxxxxxxx is a 10 digit mobile
number
delay(1000);// wait 1 seconds.
}
else if(buttonState2 == HIGH){
Serial.println("ATH"); // end call
delay(100);
}
else if(buttonState3 == HIGH){
Serial.println("ATA"); // end call
delay(100);
}
Serial.write("AT+CPAS");
delay(3);
while(Serial.available()){
delay(3);
y=Serial.read();
if(y==3) //if call is ringing/not received
{
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
}
else if(y==4) //if call is received/answered
{
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
}
}
}
uploaded.txt (1.17 KB)