Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ---------SMS-----------//
- #include "SIM900.h"
- #include <SoftwareSerial.h>
- //Carrega a biblioteca SMS
- #include "sms.h"
- SMSGSM sms;
- int numdata;
- boolean started=false;
- char smsbuffer[160];
- char n[20];
- // ----------------------//
- // ---------Rele---------//
- int porta_rele1 = 7;
- //----------------------//
- void setup()
- {
- pinMode(porta_rele1, OUTPUT);
- Serial.begin(9600);
- Serial.println("Testando GSM shield...");
- //Inicia a configuracao do Shield
- if (gsm.begin(2400))
- {
- Serial.println("nstatus=READY");
- started=true;
- }
- else Serial.println("nstatus=IDLE");
- }
- void loop()
- {
- leitura_sensores();
- envia_sms();
- }
- void leitura_sensores()
- {
- // -----------------------------------------//
- int sensorValue = analogRead(A0);
- Serial.println(sensorValue);
- delay(2000);
- // -----------------------------------------//
- if (sensorValue <= 1000)
- {
- pinMode(porta_rele1, LOW);
- }
- else
- {
- pinMode(porta_rele1, HIGH);
- }
- }
- void envia_sms()
- {
- if(started)
- {
- if (sms.SendSMS("+5562XXXXXXX", "Sistema Ligado"))
- Serial.println("nSMS sent OK");
- }
- else
- {
- // --- Sistema Desligado ---
- if(started)
- {
- if (sms.SendSMS("+5562XXXXXXX", "Sistema Desligado"))
- Serial.println("nSMS sent OK");
- }
- }
- }
- // --------Fim SMS-------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement