tobeedelafuente

fona.ino

Mar 30th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include "Adafruit_FONA.h"
  2.  
  3. #define POWER_PIN 22
  4. #define FONA_RST 23
  5.  
  6. Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
  7.  
  8. void setupFona() {
  9.   pinMode(POWER_PIN, OUTPUT);
  10.   digitalWrite(POWER_PIN, LOW);
  11.   delay(1000);
  12.   digitalWrite(POWER_PIN, HIGH);
  13.   delay(2000);
  14.   digitalWrite(POWER_PIN, LOW);
  15.   delay(3000);
  16.   Serial1.begin(4800);
  17.   while(!fona.begin(Serial1));
  18.   deleteMessages();
  19.  
  20.   Serial.println("Setup Fona done");
  21. }
  22.  
  23. boolean sendSMS(String number, String message) {
  24.   return fona.sendSMS(number.c_str(), message.c_str()) ;
  25. }
  26.  
  27. void deleteMessages() {
  28.   int slot = 15;
  29.   while(slot > 0) {
  30.     fona.deleteSMS(slot);
  31.     slot--;
  32.   }
  33.  
  34.   Serial.println(F("Deleting all messages"));
  35. }
Advertisement
Add Comment
Please, Sign In to add comment