I am reading data from an Arduino. This data is being written into a file on the Raspi. The way it works now is that as soon as the Arduino sends anything, the Raspi immediatly writes the file. What I would like to have is that the file is only written, when a button was pushed before. So as long as the button is not pressed, no file will be written, altough data is being sent / received.
On the attached image are the basic nodes (without the buttons). Somehow the button(s) need to interfere with the connection marked in green on the image, but I don't know how to do this. I cannot just insert a button, because in fact I have two buttons and the user has to click one of them before the file should be created.
see code below: