miércoles, 3 de junio de 2015

Mandar sms con dos números aleatorios

#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8);
int x,y;
String textForSMS;

void setup()
{
  mySerial.begin(19200);
  randomSeed(analogRead(0));
}
 
void sendSMS(String message)
{
  mySerial.print("AT+CMGF=1\r");    // AT command to send SMS message
  delay(100);
  mySerial.println("AT + CMGS = \"609477948\"");  // recipient's mobile number
  delay(100);
  mySerial.println(message);                         // message to send
  delay(100);
  mySerial.println((char)26);                        // End AT command with a ^Z, ASCII code 26
  delay(100);
  mySerial.println();
  delay(5000);                                     // give module time to send SMS
                               
}

void loop()
{
  x = random(0,255);
  y = random(0,255);
  textForSMS = "Tus numeros aleatorios son: ";
  textForSMS.concat(x);
  textForSMS = textForSMS + " y ";
  textForSMS.concat(y);
  textForSMS = textForSMS + ". Suerte!";
  sendSMS(textForSMS);
  do {} while (1);
}

No hay comentarios:

Publicar un comentario