Stap 6: SMS Texting logica
Nu we in de code dat ons toelaat voegen om een SMS-bericht verzenden met een vooraf vastgestelde vriend, wanneer we het nodig hebben een "Bel op lijn 1" soort van de onderbreking. Het is eigenlijk vrij eenvoudig. Alles wat we moeten doen is de LGSM bibliotheek en maak vervolgens een paar lijnen van code voor het verzenden van een tekst.
<p>#include defs.h<br>#include i2d.h #include i2c_touc_sensor.h #include mpr121.h #include types.h #include Wire.h #include LGSM.h // IMPORTANT: in this case, INT pin was connected to pin7 of the LinkIt One // (this is the interrupt pin) i2ctouchsensor touchsensor; // keep track of 4 pads' states //boolean padTouched[4]; long previousMillis = 0; long interval = 100; void setup() { Serial.begin(9600); // for debugging Serial.print("begin to init"); Wire.begin(); // needed by the GroveMultiTouch lib touchsensor.initialize(); // initialize the feelers </p><p> // initialize the containers for(int i=0; i<=3; i++) { padTouched[i]=false; } } void loop() { unsigned char MPR_Query=0; unsigned long currentMillis = millis(); if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; touchsensor.getTouchState(); } for (int i=0;i<12;i++) { if (touchsensor.touched&(1<<i))</p><p></p><p style="margin-left: 20.0px;"> LSMS.beginSMS("5551112222"); //Insert phone number you wish to notify LSMS.print("PLEASE COME TO MY DESK WITH EXCUSE FOR ME TO LEAVE"); LSMS.endSMS(); } } }</p>