How to raise an interrupt from existing ADC

God Bless you guys for the wonderful endeavor you are living up to.

Novice, please …

This is my code:


adc = pyb.ADC(pyb.Pin(‘P6’))
adcread=0

#while (True):
adcread=adc.read()
if (adcread>250):
clock.tick()
img = sensor.snapshot()

Do machine vision algorithms on the image here


print(clock.fps())

I need the Cam to consume as less power as possible until ‘adcread’ is greater than 250.
Once ‘adcread’ becomes greater than 250, the while loop should work and, thereafter, when ‘adcread’ falls below the value of 250, the Cam should go back to low power mode.

I understand that interrupts can be of use here. But how to raise an interrupt from ADC which continuously raises and falls?

Or, is there any completely different approach to this, please?

BTW … I’m on H7, please.

I don’t think you can do that, there’s no sleep/wake on ADC at least not that I know of. Alternatively you could just put the cam in low power, wake up, check adc and back to low power etc…

while (true):
check_adc()
if (adc < 250):
sleep
else:
do something else.

See the low power examples in Examples->19-Low-Power

Thank you very much for the quick response.
:smiley: