انجمن تخصصی رباتیک و الکترونیک

  1. Clash.kingfarsi@gmail.com
  2. میکروکنترلرها و متعلقات آن
  3. شنبه, 28 آوریل 2018
  4.  اشتراک از طریق ایمیل
سلام مشکل این کد چیه؟ منظور کامپایلرو متوجه نمیشم
کد

// { relay control program with SMS

//the program is written entirely by [Amir Hossein Mohammadian]

//this code is also for Microcontroller [ATMEGA328] }



#include <Sim800l.h>
#include <SoftwareSerial.h>

Sim800l Sim800l;
String textSms;
String numberSms;
uint8_t LED1 = 4 ; // Connected to relay 1
uint8_t LED2 = 5 ; // Connected to relay 2
uint8_t LED3 = 6 ; // Connected to relay 3
uint8_t LED4 = 7 ; // Connected to relay 4
uint8_t LED5 = 8 ; // Connected to relay 5
uint8_t LED6 = 9 ; // Connected to relay 6
uint8_t LED7 = 12 ; // Connected to relay 7
uint8_t LED8 = 13 ; // Connected to relay 8
uint8_t LED9 = 2 ; // connected to relay 9
uint8_t LED10 = 3 ; // connected to relay 10
uint8_t LED11 = A0 ;// connected to relay 11
uint8_t LED12 = A1 ;// connected to relay 12
uint8_t LED13 = A2 ;// connected to relay 13
uint8_t LED14 = A3 ;// connected to relay 14
uint8_t LED15 = A4 ;// connected to relay 15
uint8_t LED16 = A5 ;// connected to relay 16

bool error;

void setup ()
{
Serial.begin ( 9600 );
pinMode (LED1, OUTPUT);
pinMode (LED2, OUTPUT);
pinMode (LED3, OUTPUT);
pinMode (LED4, OUTPUT);
pinMode (LED5, OUTPUT);
pinMode (LED6, OUTPUT);
pinMode (LED7, OUTPUT);
pinMode (LED8, OUTPUT);
pinMode (LED9, OUTPUT);
pinMode (LED10, OUTPUT);
pinMode (LED11, OUTPUT);
pinMode (LED12, OUTPUT);
pinMode (LED13, OUTPUT);
pinMode (LED14, OUTPUT);
pinMode (LED15, OUTPUT);
pinMode (LED16, OUTPUT);
Sim800l.begin ();
Serial.print ( "Clearing old SMS ..." );
error = Sim800l.delAllSms ();
Serial.println ( "Off!" );
Serial.println ( "\nSaving SMS commands ..." );
}

void loop ()
{

textSms = Sim800l.readSms ( 1 );


if (textSms.indexOf ( "OK" ) != - 1 )
{

if (textSms.length () > 7 )
{

numberSms = Sim800l.getNumberSms ( 1 );

Serial.println (numberSms);

textSms.toUpperCase ();



Serial.println ( "Led 1 On" );
digitalWrite (LED1, 1 );
}

else if (textSms.indexOf ( "D1" ) != - 1 )
{
Serial.println ( "Led 1 Off" );
digitalWrite (LED1, 0 );
}

else if (textSms.indexOf ( "L2" ) != - 1 )
{
Serial.println ( "Led 2 On" );
digitalWrite (LED2, 1 );
}
else if (textSms.indexOf ( "D2" ) != - 1 )
{
Serial.println ( "Led 2 Off" );
digitalWrite (LED2, 0 );
}
if (textSms.indexOf ( "L3" ) != - 1 )
{
Serial.println ( "Led 3 On" );
digitalWrite (LED3, 1 );
}

else if (textSms.indexOf ( "D3" ) != - 1 )
{
Serial.println ( "Led 3 Off" );
digitalWrite (LED3, 0 );
}
else if (textSms.indexOf ( "L4" ) != - 1 )
{
Serial.println ( "Led 4 On" );
digitalWrite (LED4, 1 );
}
else if (textSms.indexOf ( "D4" ) != - 1 )
{
Serial.println ( "Led 4 Off" );
digitalWrite (LED4, 0 );
}
if (textSms.indexOf ( "L5" ) != - 1 )
{
Serial.println ( "Led 5 On" );
digitalWrite (LED5, 1 );
}

else if (textSms.indexOf ( "D5" ) != - 1 )
{
Serial.println ( "Led 5 Off" );
digitalWrite (LED5, 0 );
}

else if (textSms.indexOf ( "L6" ) != - 1 )
{
Serial.println ( "Led 6 On" );
digitalWrite (LED6, 1 );
}
else if (textSms.indexOf ( "D6" ) != - 1 )
{
Serial.println ( "Led 6 Off" );
digitalWrite (LED6, 0 );
}
if (textSms.indexOf ( "L7" ) != - 1 )
{
Serial.println ( "Led 7 On" );
digitalWrite (LED7, 1 );
}

else if (textSms.indexOf ( "D7" ) != - 1 )
{
Serial.println ( "Led 7 Off" );
digitalWrite (LED7, 0 );
}

else if (textSms.indexOf ( "L8" ) != - 1 )
{

Serial.println ( "Led 8 On" );
digitalWrite (LED8, 1 );

}

else if (textSms.indexOf ( "D8" ) != - 1 )
{
Serial.println ( "Led 8 Off" );
digitalWrite (LED8, 0 );
}

}
if (textSms.indexOf ( "L9" ) != - 1 )
{
Serial.println ( "Led 9 On" );
digitalWrite (LED9, 1 );
}

else if (textSms.indexOf ( "D9" ) != - 1 )
{
Serial.println ( "Led 9 Off" );
digitalWrite (LED9, 0 );
}

else if (textSms.indexOf ( "L10" ) != - 1 )
{

Serial.println ( "Led 10 On" );
digitalWrite (LED10, 1 );

}

else if (textSms.indexOf ( "D10" ) != - 1 )
{
Serial.println ( "Led 10 Off" );
digitalWrite (LED10, 0 );

}


if (textSms.indexOf ( "L11" ) != - 1 )
{

Serial.println ( "Led 11 On" );
digitalWrite (LED11, 1 );

}

else if (textSms.indexOf ( "D11" ) != - 1 )
{
Serial.println ( "Led 11 Off" );
digitalWrite (LED11, 0 );

}
if (textSms.indexOf ( "L12" ) != - 1 )
{
Serial.println ( "Led 12 On" );
digitalWrite (LED12, 1 );
}

else if (textSms.indexOf ( "D12" ) != - 1 )
{
Serial.println ( "Led 12 Off" );
digitalWrite (LED12, 0 );
}

if (textSms.indexOf ( "L13" ) != - 1 )
{

Serial.println ( "Led 13 On" );
digitalWrite (LED13, 1 );

}

else if (textSms.indexOf ( "D13" ) != - 1 )
{
Serial.println ( "Led 13 Off" );
digitalWrite (LED13, 0 );
}

}
else if (textSms.indexOf ( "L14" ) != - 1 )
{
Serial.println ( "Led 14 On" );
digitalWrite (LED14, 1 );
}

else if (textSms.indexOf ( "D14" ) != - 1 )
{
Serial.println ( "Led 14 Off" );
digitalWrite (LED14, 0 );
}
else if (textSms.indexOf ( "L15" ) != - 1 )
{

Serial.println ( "Led 15 On" );
digitalWrite (LED15, 1 );

}

else if (textSms.indexOf ( "D15" ) != - 1 )
{
Serial.println ( "Led 15 Off" );
digitalWrite (LED15, 0 );

}


else if (textSms.indexOf ( "L16" ) != - 1 )
{

Serial.println ( "Led 16 On" );
digitalWrite (LED16, 1 );

}
else if (textSms.indexOf ( "D16" ) != - 1 )
{
Serial.println ( "Led 16 Off" );
digitalWrite (LED16, 0 );

}

Sim800l.delAllSms ();

}
پیوست‌ها
saeed پاسخ پذیرفته شده
سلام
لطفا رایبرری ها رو هم آپلود کنید
کامنت ها
هنوز کامنتی ارسال نشده است
Clash.kingfarsi@gmail.com پاسخ پذیرفته شده
بفرمایید
پیوست‌ها
کامنت ها
هنوز کامنتی ارسال نشده است
Clash.kingfarsi@gmail.com پاسخ پذیرفته شده
سلام
مشکل پیدا نشد؟
کامنت ها
هنوز کامنتی ارسال نشده است
  • صفحه :
  • 1


هنوز به این بحث پاسخی داده نشده است.
شما نیز اجازه ارسال پاسخ را ندارید