Function constant looping

I try to write a code to loop function all the time but I haven’t success…
Any suggestions how it can be done correctly?
To keep imp online I use rssi function including "imp.wakeup(60, show_rssi);"
For example:
function strobe() { pin1State =; if(pin1State != pin1StatePerv && pin1State == 1) { adc =; adcS += adc/64; count+=1; } pin1StatePerv = pin1State; } strobe();

What function do you want to loop? Unlike an Arduino, you don’t need a constantly looping function, you can just schedule functions to run with imp.wakeup();

…and you’ll make @beardedinventor very sad if you don’t use code tags. :slight_smile:

@jwehr imp.wakeup() I cannot used due to fact - I need to synchronise function with other frequency.
I suppose - I remember solution: instead of hardware.pin1.configure(DIGITAL_IN_PULLUP); I apply hardware.pin1.configure(DIGITAL_IN_PULLUP,function to call);
At first sight it like to work.
I have done that before some half year ago but have forget due to all other projects in my head…:slight_smile:

Wrapped you code in a code tag @PeterAP :wink:

You’re spot on - you can supply an optional second parameter to…) that will be called whenever the state changes from HIGH to LOW or LOW to HIGH:

function buttonStateChanged() { local pinState =; if (pinState == 1) { adc =; adcS += adc/64; count+=1; } }

@beardedinventor , thanks!
Is it possible to find some idea about mentioned function speed - what is the shortest pulse imp can detect via this function - state change detect?

I try to detect about 16 microsecond LOW pulse repeating with frequency about 4KHz.
And it miss about every second pulse…