Go Down

Topic: Gsm remote control on off a/c with sony ericsson k700 (Read 1 time) previous topic - next topic

power7net

Hi i connect arduino mega328 with sony ericsson k700 and control a/c by sms....

Code: [Select]

//GSM Remote control  V 1.0 (13/12/2011)

int IRledPin=13; //IR led pin
String readString;
char c;

void delsms(){
   Serial.println("AT+CMGD=1");//Delete sms
   }
void readsmsAT(){
  Serial.println("AT+CMGR=1");//Read sms AT command
  delay(5000);
  }

void pulseIR(long microsecs) {
 // we'll count down from the number of microseconds we are told to wait
 
 cli();  // this turns off any background interrupts
 
 while (microsecs > 0) {
   // 38 kHz is about 13 microseconds high and 13 microseconds low
  digitalWrite(IRledPin, HIGH);  // this takes about 3 microseconds to happen
  delayMicroseconds(10);         // hang out for 10 microseconds
  digitalWrite(IRledPin, LOW);   // this also takes about 3 microseconds
  delayMicroseconds(10);         // hang out for 10 microseconds

  // so 26 microseconds altogether
  microsecs -= 26;
 }
 
 sei();  // this turns them back on
}

void SendACCodeOn() {
 // This is the code for my particular Toyotomi on button
 
 pulseIR(9000);
 delayMicroseconds(4340);
 pulseIR(840);
 delayMicroseconds(320);
 pulseIR(740);
 delayMicroseconds(400);
 pulseIR(700);
  delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 for(int x=0 ; x< 5 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 
 delayMicroseconds(400);
 pulseIR(700);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(400);
 pulseIR(700);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 
 delayMicroseconds(340);
 pulseIR(760);
 for(int x=0 ; x< 4 ; x++){
 delayMicroseconds(1440);
 pulseIR(740);
 }
 delayMicroseconds(340);
 pulseIR(760);
 for(int x=0 ; x< 3 ; x++){
 delayMicroseconds(1440);
 pulseIR(740);
 }
 for(int x=0 ; x< 7 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(1440);
 pulseIR(740);
 }
 for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(1440);
 pulseIR(740);
 }
 for(int x=0 ; x< 9 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(500);
 
}

void SendACCodeOff() {
 // This is the code for  Toyotomi off button
 
 pulseIR(9000);
 delayMicroseconds(4340);
 pulseIR(840);
 delayMicroseconds(320);
 pulseIR(740);
 delayMicroseconds(400);
 pulseIR(700);
  delayMicroseconds(1440);
 pulseIR(740);
 
 delayMicroseconds(380);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 for(int x=0 ; x< 5 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 
 delayMicroseconds(400);
 pulseIR(700);
 
 delayMicroseconds(400);
 pulseIR(700);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(380);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(760);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(760);
 delayMicroseconds(360);
 pulseIR(760);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 for(int x=0 ; x< 4 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 delayMicroseconds(1440);
 pulseIR(740);
 for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }
 for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(1440);
 pulseIR(740);
 }
 for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }  
  for(int x=0 ; x< 6 ; x++){
 delayMicroseconds(1440);
 pulseIR(740);
 }
 for(int x=0 ; x< 9 ; x++){
 delayMicroseconds(360);
 pulseIR(740);
 }  
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(740);
 delayMicroseconds(1440);
 pulseIR(740);
 delayMicroseconds(360);
 pulseIR(740);
}

 void setup() {
 
 pinMode(IRledPin,OUTPUT);
 delay(12000);//first time connect cable arduino with phone...
 Serial.begin(9600);
 delay(3000);
 Serial.println("AT+CPMS=\"ME\",\"SM\"");//Set memory phone
 delay(3000);
 Serial.println("ATE=0");//Echo off
 delay(3000);

}

 
 void loop()
 {
      readString=0;//format readString...
      readsmsAT();
   
  // read phone reply if available
while(Serial.available() > 0)
           {
               c=Serial.read(),BYTE;
               readString+=c;
           }
              delay(1000);
             
              Serial.println(readString);//serial monitor display sms pdu format
             
              delay(3000);
             if (readString.indexOf("9624162751")>0 && readString.indexOf("36F770C")>0)// admin number and pdu on
             {
                //digitalWrite(IRledPin, HIGH);//only for test
                SendACCodeOn();//AC Toyotomi on
                delay(7000);
                //digitalWrite(IRledPin, LOW);//only for test
             }
             if (readString.indexOf("9624162751")>0 && readString.indexOf("44FA33106")>0)// admin number and pdu off
             {
                //digitalWrite(IRledPin, HIGH);//only for test
                SendACCodeOff();//AC Toyotomi off
                delay(3000);
                //digitalWrite(IRledPin, LOW);//only for test
             }
             if (readString.length()>40)//delete sms if sms received
             {
             delsms();
     }
             delay(20000);//delay start loop again for check new sms...

 }


Web / sms / bluetooth / arduino / android remote control. Home Automation projects.
http://www.power7.net

PeterH

I only provide help via the forum - please do not contact me for private consultancy.

power7net

How i send sms from arduino with temperature from sensor(analog input)?
Web / sms / bluetooth / arduino / android remote control. Home Automation projects.
http://www.power7.net

Go Up