Go Down

Topic: control wled  (Read 649 times) previous topic - next topic

merci

Jul 24, 2015, 01:11 pm Last Edit: Jul 24, 2015, 01:13 pm by merci
I tried to control the led with sms but doesn't work,, the led not turn on,
when I compiled and upload there's no errro with the code, but why its doesnt work,,
please help me..
I use arduino uno and icomsat v1.1 sim900
here is the code
Code: [Select]
char inchar; //Will hold the incoming character from the Serial Port.


 int led1 = 9;
 int led2 = 10;
 int led3 = 11;
 int led4 = 12;

 void setup()
 {
 // prepare the digital output pins
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
 digitalWrite(led1, LOW);
 digitalWrite(led2, LOW);
 digitalWrite(led3, LOW);
 digitalWrite(led4, 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"); // set SMS mode to text
 delay(200);
 Serial.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt
 delay(200);
 }

 void loop()
 {
 //If #a1b1c1d1 comes as sms, all led's should light up.
 if(Serial.available() >0)
 {
 inchar=Serial.read();
 if (inchar=='#')
   {
   delay(10);
   inchar=Serial.read();

 //first led
   if (inchar=='a')
     {
   delay(10);
   inchar=Serial.read();

 if (inchar=='0')
   {
   digitalWrite(led1, LOW);
   }
 else if (inchar=='1')
   {
   digitalWrite(led1, HIGH);
   }
 delay(10);


 //Second led
 inchar=Serial.read();

 if (inchar=='b')
   {
   inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led2, LOW);
 }

 else if (inchar=='1')
 {
 digitalWrite(led2, HIGH);
 }
 delay(10);

 // Third led
 inchar=Serial.read();
 if (inchar=='c')
 {
 inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led3, LOW);
 }
 else if (inchar=='1')
 {
 digitalWrite(led3, HIGH);
 }
 delay(10);

 //Fourth led

 inchar=Serial.read();
 if (inchar=='d')
 {
 delay(10);
 inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led4, LOW);
 }
 else if (inchar=='1')
 {
 digitalWrite(led4, HIGH);
 }
 delay(10);
 }
 }
 Serial.println("AT+CMGD=1,4"); // delete all SMS
 }
 }
 }
 }
 }

ProfRon

CHeck the CHIP set number if you have 4 it may have to be 10

Go Up