Interrupt for-loop on Raspberry Pi

This is indeed exactly my setup! :+1: Thanks for the clarification!
In the Client (browser), i will copy 3 values to the Raspberry pi:

In the Raspberry Pi, the following function will we executed, because this is called by the Client:
image

The for-loop will start when the checkbox is checked in the Client.
image

Let’s say this for-loop last for 20 min. After 10 min, you encounter a problem and you want to stop the motor. So my first reaction will be: uncheck the checkbox in the Client:

image

So at the end of the for-loop,I want to call for the status of this checkbox:
if the checkbox is checked, continue with the for-loop, if not checked: break.

image

So I have to make a call from the Raspberry Pi --> the Client! And this is the problem I think. Is it possible to call the Client and ask for the status of the checkbox ‘Motor AAN’ at that moment?

If not, I was trying this:
I thought this might work: Raspberry Pi --> Server (Anvil) --> Client (Webbrowser)

I saw this in one of your comments on the forum: Calling user input in the server
For testing, I made a new checkbox in my Client:
image
If this is pressed,this will happen:

image
And this will be executed on the Anvil server:
image

In the Raspberry Pi, I will implement this code:
image

Afterwards, I get this message:


I guess it’s because this is not yet executed in the Client:
image

But I’m not really sure if it’s possible to make a call from the Raspberry Pi to the Client. That’s why I wanted to ask first if this a good path or I should change it up and install a physicall button on my Raspberry Pi that acts as ‘an emergency button’. :thinking: It is not ideal, because in this way, you cannot turn off your motor using a web application, which is really cool.

In the end, I just want to start and stop the motor with the website.

Hope this makes things a bit clearer. Sorry for the miscommunication. It’s my first time using a server-client, so it’s all a bit new to me. And it makes it all more complicated, if you add a third player (Raspberry Pi)!