You shouldn’t use any functions like that in a Builder script (i.e. ones which impose any sort of delay or sleep period). Builder scripts maintains a timing system by actively drawing to the display on every screen refresh, typically at 60 Hz. By sleeping for 400 ms, you will break that drawing cycle (in this case, causing Builder to lose track of at least 24 screen refreshes on a 60 Hz display). This might cause unexpected timing errors for the other component you have created.
Builder maintains its own variable called
t that keeps track of the time elapsed in seconds since the start of the current routine (as long as you don’t put it to sleep). So you can check the time and send the pulse, but also need to check that you do it only once. So put this in the “begin routine” tab, deleting the code that is there currently:
trigger_sent = False
and then put this in the “each frame” tab (so that the code will run on each screen refresh):
if not trigger_sent and t >= 0.4:
port.write(bytes(1)) # or whatever is appropriate
trigger_sent = True