int speaker = 9;
int frequency1 = 31000;
int frequency2 = 41000;
int frequency3 = 51000;
int frequency4 = 61000;
int frequency5 = 2000;
unsigned char Buff[250];
unsigned char BuffIndex ;
void setup() {
// put your setup code here, to run once:
pinMode(speaker,OUTPUT);
Serial.begin(9600);
delay(3000);
Serial.print("ATS0=2\r\n");
delay (3000);
Serial.print("AT+DDET=1\r\n");
delay(3000);
memset(Buff,'\0',250); //initialize the string
BuffIndex = 5 ;
}
void loop()
{
// put your main code here, to run repeatedly:
while(1)
{
if(Serial.available()>0)
{
Buff[BuffIndex]= Serial.read();
if( (Buff[BuffIndex-5]=='D')&&(Buff[BuffIndex-4]=='T')&&(Buff[BuffIndex-3]=='M')&&(Buff[BuffIndex-2]=='F')&&(Buff[BuffIndex-1]==':')&&(Buff[BuffIndeX]=='0'))
{
tone(speaker , frequency1);
}
if( (Buff[BuffIndex-5]=='D')&&(Buff[BuffIndex-4]=='T')&&(Buff[BuffIndex-3]=='M')&&(Buff[BuffIndex-2]=='F')&&(Buff[BuffIndex-1]==':')&&(Buff[BuffIndeX]=='1'))
{
tone(speaker , frequency2);
}
if( (Buff[BuffIndex-5]=='D')&&(Buff[BuffIndex-4]=='T')&&(Buff[BuffIndex-3]=='M')&&(Buff[BuffIndex-2]=='F')&&(Buff[BuffIndex-1]==':')&&(Buff[BuffIndeX]=='2'))
{
tone(speaker , frequency3);
}
if( (Buff[BuffIndex-5]=='D')&&(Buff[BuffIndex-4]=='T')&&(Buff[BuffIndex-3]=='M')&&(Buff[BuffIndex-2]=='F')&&(Buff[BuffIndex-1]==':')&&(Buff[BuffIndeX]=='3'))
{
tone(speaker , frequency4);
}
if( (Buff[BuffIndex-5]=='D')&&(Buff[BuffIndex-4]=='T')&&(Buff[BuffIndex-3]=='M')&&(Buff[BuffIndex-2]=='F')&&(Buff[BuffIndex-1]==':')&&(Buff[BuffIndeX]=='4'))
{
tone(speaker , frequency5);
}
BuffIndex++
{
if(BuffIndex>250)
BuffIndex = 5;
}
}
}
}
i dont know what the error is. i have tried compiling it.