top | item 9610863

(no title)

ICWiener | 10 years ago

I am surely missing something, why would you want to delay in the function?

discuss

order

StavrosK|10 years ago

The GSM shield messes up if you poll too often, IIRC.

q3k|10 years ago

You should reevaluate your architecture.

Instead of delaying in code, think about having the main loop enter the execution routines of a few FSMs (modem FSM, i/o FSM, etc). In this model, a FSM state function can just return early if it's waiting for an even, giving execution time to other FSMs.

Of course, a better approach would be to run a RTOS on your uC, like the venerable FreeRTOS. Then you can just run tasks that can sleep, communicate via queues, and you can even get preemption if you wish. But I'm not sure it's available for the Arduino.

Additionally, since you're using a SIM90x, why are you polling the modem? Out-of-band events (incoming call, new text message) usually arrive in the form of Unsolicited Messages, like +CMTI for a new SMS or RING for an incoming call. You can interrupt on each character received via UART, and do your processing there.

BostonEnginerd|10 years ago

Debouncing the switch? Check if the input is triggered, and then check it again a short time later to see if it is still triggered.