cs <- hardware.pin8; miso <- hardware.pin7; mosi <- hardware.pin5; //self test probably sck <- hardware.pin2; // configure pin cs.configure(ANALOG_IN); miso.configure(ANALOG_IN); mosi.configure(ANALOG_IN); sck.configure(ANALOG_IN); led.configure(DIGITAL_OUT); led2.configure(DIGITAL_OUT); local x = 0; local y = 0; local z = 0; local xo = 0; local yo = 0; local zo = 0; local t = 80; local counter = 0; local smssent = 0; local stepLimit = 20; function poll() { // read pin and log x = cs.read(); y = miso.read(); z = sck.read(); if ((math.abs(x - xo) > 900) || (math.abs(y - yo) > 900) || (math.abs(z - zo) > 900)) { counter++; } if (counter == stepLimit && (smssent == 0)) { smssent = 1; agent.send("sms", "food truck outside, $1 hotdogs for the next 20 minutes"); } //reset acceleometer data xo = x; yo = y; zo = z; // wake up in 0.1 seconds and do it again imp.wakeup(1, poll); } // start the loop poll();