hello i am doing the same thing tried to use the above code but it is not working
i can control the led pin 13 using serial consol by sending 0#1 and can make off by 0#0 but when i am sending the message 0#1 the led is not glowing here is my code
can anybody tell me what is the problem??
char inchar; //Will hold the incoming character from the Serial Port.
int led1 = 13;
void setup()
{
// prepare the digital output pins
pinMode(led1, OUTPUT);
// initially all are off
digitalWrite(led1, LOW);
//Initialize GSM module serial port for communication.
Serial.begin(9600);
delay(3000); // give time for GSM module to register on network etc.
Serial.println("AT+CMGF=1\r"); // set SMS mode to text
delay(200);
Serial.println("AT+CSMS=1\r");
delay(200);
//Serial.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt
Serial.println("AT+CNMI=2,2,0,0,0"); // set module to send SMS data to serial out upon receipt
//Serial.println("AT+CSMP=17,167,0,0");
delay(200);
}
void loop()
{
//If a character comes in from the Serialular module...
if(Serial.available() >0)
{
delay(10);
inchar=Serial.read();
if (inchar=='0') // to catch the 1st 0 in our string 0#101#101#101
{
// digitalWrite(led1, HIGH);
// for #101________________
inchar=Serial.read(); // read next char i.e '#'
if (inchar=='#')
{
inchar=Serial.read(); //read next char i.e 1
if (inchar=='0')
{
digitalWrite(led1, LOW);
}
else if (inchar=='1')
{
digitalWrite(led1, HIGH);
}
} //end of 3rd 'if char==#' loop
} // "ckeck 0 in front of string" wala loop close
//Serial.println("AT+CMGD=1,4"); // delete all SMS
} // serial available condition close
// Serial.println("AT+CMGR=1\r");
// delay(4000);
} // LOOP function close