/* SMS sender Circuit: * LinkIt One * SIM card that can send SMS Source http://labs.mediatek.com/forums/posts/list/425.page */ // Include LGSM library #include // initialize the library instance LSMSClass gsmAccess; LSMSClass sms; const int DigInPin = 7; // "BattMon" sensor I/P const int ledPinSCK = 13; // LED on D13 "StandBy" const int ledPinRX = 0; // LED on D0 "RX BattMon" const int ledPinTX = 1; // LED on D1 "TX Sending SMS" int ledStateRX = LOW; // ledState used to set the LED int ledStateTX = LOW; // ledState used to set the LED unsigned long previousMillis = 0; // will store last time RXled was updated unsigned long waitMillis = 0; // start wait time for TXled const long interval = 500; // interval at which to blink (milliseconds) const long waitInterval = 10000; // interval for TXled to wait (milliseconds) char remoteNum[] = "07123456789"; // telephone number to send sms char txtMsg[] = "BattMon - Low Volts, Charge required"; // sms text void setup() { pinMode(DigInPin, INPUT); // sets the digital pin as input pinMode(ledPinSCK, OUTPUT); // sets the digital pin as output pinMode(ledPinRX, OUTPUT); // sets the digital pin as output pinMode(ledPinTX, OUTPUT); // sets the digital pin as output } void loop() if DigInPin == LOW { // show something is working, "delay" gives a 2 sec sample rate on DigInPin digitalWrite(ledPinSCK, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPinSCK, LOW); // sets the LED off delay(1000); // waits for a second } if DigInPin == HIGH // things just got urgent { // don't "delay", move led, blink quicker, wait "waitinterval" secs before texting // count down timer code here unsigned long currentMillis = millis(); if (currentMillis - waitMillis >= waitInterval) { ledStateRX = HIGH; /* send the message...... sms.beginSMS(remoteNum); sms.print(txtMsg); sms.endSMS(); ....... when dev stage works. Would be good to pulse tooth brush motor here for audible alarm */ } // check to see if it's time to blink the LED; that is, if the // difference between the current time and last time you blinked // the LED is bigger than the interval at which you want to // blink the LED. if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; // save the last time you blinked the LED if (ledStateRX == LOW) // if the LED is off turn it on and vice-versa: { ledStateRX = HIGH; } else { ledStateRX = LOW; } digitalWrite(ledPinRX, ledStateRX); // set the LED with the ledState of the variable: } } //========================================END