Boas Pessoal,
Ja tenho este programa que eu envio uma mensagem e ele ativa um led ou desliga depende da ordem de mensagem. Mas agora pretendia adicionar neste programa o seguinte:
Quando pressiono um botão ele liga um led e manda uma mensagem.
Me ajudem pessoal!!!
Cumprimentos
Pedro Branco
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
String numeroRemetente; //Variável para o armazenamento do número do remetente da SMS
String numeroPermitido = "+351912233233"; //Variável que define o número do celular que o sistema irá responder
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
char phone_num[20]; // array for the phone number string
char sms_text[160]; // array for the SMS text string
char position;
String numeros;
String numero;
String msg;
String aux;
void setup(){
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(9600)){
Serial.println("\nstatus=READY");
started=true;
}else{
Serial.println("\nstatus=IDLE");
}
if(started){
//Enable this two lines if you want to send an SMS.
// if (sms.SendSMS("9090981014676", "Teste SMS Arduino!"))
// Serial.println("\nSMS sent OK");
}
pinMode(10,OUTPUT);
};
void loop(){
if(started){
//Read if there are messages on SIM card and print them.
position = sms.IsSMSPresent(SMS_UNREAD);
if(position){
if(sms.GetSMS(position, phone_num, sms_text, 160)){
numeroRemetente = phone_num;
msg = sms_text;
if(numeroRemetente != numeroPermitido){
Serial.println("Nao Permitido");
}
else {
Serial.println("Permitido");
if(msg == "on"){
digitalWrite(10,HIGH);
}else if(msg == "off"){
digitalWrite(10,LOW);
}else if(msg == "ciclo"){
digitalWrite(10,HIGH);
delay(6000);
digitalWrite(10,LOW);
sms.SendSMS(phone_num, "Arduino fez o ciclo!");
}
}
Serial.println(phone_num);
Serial.println(sms_text);
//sms.SendSMS(phone_num, sms_text);
}
sms.DeleteSMS(position);
memset(&sms_text,NULL,sizeof(sms_text));
}
delay(1000);
}
};
Tags:
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por